A bit out of sequence, as I haven't covered cooling fan control or music streaming yet, but today I added a double-tap feature to VoiceBox.py.
DOUBLEPRESS = 1.0 # Button is double-pressed if twice within 1 second
def button_wait_thread():
global last_button_time
button = aiy.voicehat.get_button()
while mode != 'quit':
button.wait_for_press()
button_press_time = time.time()
if button_press_time - last_button_time < DOUBLEPRESS:
print('Double-press, killing music and fan')
fan('off', quiet=True) # switch off fan without fanfare
music('off', quiet=True)
else:
print('Button pressed, enabling mic')
response = requests.get('http://localhost:9011/button')
last_button_time = button_press_time
So, if the button is pressed twice within a second, the music and cooling fan are switched off. I added this feature because when the fan is on, and the radio announcer is talking, Google Assistant can really struggle to understand commands (such as "music off" and "cooling fan off"!).
Before the fix, I was using the GPIO control tab of piHole at <your-pi's-ip-address>:9012/gpio to switch off the "COOLING FAN". If the radio got really loud I'd have to ssh in and "mpc stop" from the command line to kill the radio manually.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.