https://matthewfelgate.wordpress.com/2022/12/14/turn-the-radio-volume-down-for-adverts-and-djs-talking/ Skip to content Matthew Felgate My thoughts, electronics and adventures Turn The Radio Volume Down For Adverts and DJs talking. matthewfelgate Uncategorized December 14, 2022December 14, 2022 1 Minute A script for automatically lowering the volume during radio advertisements and DJ announcements and turns the volume back up when songs are playing. It controls a Sonos speaker using the Soco-cli Python library when Tunein is being used. # Radio control. # Sets volume low when radio is not playing a song (Talking or Ad Break) on TuneIn. # Docs https://github.com/avantrec/soco-cli/blob/v0.4.52/README.md import time from soco_cli import api quiet_volume = "15" # Volume for Advertising breaks or Talking. # Get current volume to set volume to after we have turned it down exit_code, previous_volume, error = api.run_command("Main Office", "volume") print("Starting volume is ", previous_volume) while(True): # See if someone has changed the volume and record that exit_code, current_volume, error = api.run_command("Main Office", "volume") if int(current_volume) > int(quiet_volume): previous_volume = current_volume print("Volume changed to ", previous_volume) # Find what song if any is playing exit_code, output, error = api.run_command("Main Office", "track") print(output) # See if track details have an artist which tells us a song is playing if "Artist" in output: print ("Playing a song. Set volume to", previous_volume,".") exit_code, new_volume, error = api.run_command("Main Office", "volume", previous_volume) else: print ("Not playing a song. Set volume to", quiet_volume) exit_code, text, error = api.run_command("Main Office", "volume", quiet_volume) time.sleep(5) Advertisement Share this: * Twitter * Facebook * Like this: Like Loading... Related [5eddabc0eb] Published by matthewfelgate View all posts by matthewfelgate Published December 14, 2022December 14, 2022 Post navigation Previous Post Google is Dead: The Future of Search is Chat. Leave a Reply Cancel reply Enter your comment here... [ ] Fill in your details below or click an icon to log in: * * * * Gravatar Email (required) (Address never made public) [ ] Name (required) [ ] Website [ ] WordPress.com Logo You are commenting using your WordPress.com account. ( Log Out / Change ) Twitter picture You are commenting using your Twitter account. ( Log Out / Change ) Facebook photo You are commenting using your Facebook account. ( Log Out / Change ) Cancel Connecting to %s [ ] Notify me of new comments via email. [ ] Notify me of new posts via email. [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Website Built with WordPress.com. [Close and accept] Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy * Follow Following + [wpcom-] Matthew Felgate [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [wpcom-] Matthew Felgate + Customize + Follow Following + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar %d bloggers like this: [b]