#!/usr/bin/env python3
import aiy.audio
import aiy.cloudspeech
import aiy.voicehat
import subprocess
def main():
recognizer = aiy.cloudspeech.get_recognizer()
button = aiy.voicehat.get_button()
aiy.audio.get_recorder().start()
scroll = subprocess.Popen([
"/usr/bin/python","scrolling-text.py",
"Press the button and speak"])
while True:
print('Press the button and speak')
button.wait_for_press()
scroll.kill()
sinewave = subprocess.Popen(["/usr/bin/python","sine-wave.py"])
print('Listening...')
text = recognizer.recognize()
sinewave.kill()
if text is None:
print('Sorry, I did not hear you.')
else:
text = text + " "
scroll = subprocess.Popen(["/usr/bin/python","scrolling-text.py",text])
print('You said "', text, '"')
if __name__ == '__main__':
main()