Skip to content

Instantly share code, notes, and snippets.

@jiansoo
Last active February 27, 2019 13:54
Show Gist options
  • Save jiansoo/b4e93780e1adedc8af7810c762c8658e to your computer and use it in GitHub Desktop.
Save jiansoo/b4e93780e1adedc8af7810c762c8658e to your computer and use it in GitHub Desktop.
import signal
import snowboydecoder
import interpret
interrupted = False
int = interpret.Recognise()
def interrupt_func(signal, frame):
global interrupted
interrupted = True
def interrupt_callback():
global interrupted
return interrupted
detector = snowboydecoder.HotwordDetector('Athena.pmdl', sensitivity=0.5)
signal.signal(signal.SIGINT, interrupt_func)
def start_speech_recognition():
detector.terminate()
print('Speech recognition started!')
val = int.detect()
print(val)
start_detection()
def start_detection():
detector.start(detected_callback=start_speech_recognition,
interrupt_check=interrupt_callback,
sleep_time=0.03)
start_detection()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment