Created
February 27, 2019 13:46
-
-
Save jiansoo/7b81f2b99d3f0105dd3eff4a2a3ceb7c to your computer and use it in GitHub Desktop.
Snowboy Model Python Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import snowboydecoder | |
import sys | |
import signal | |
interrupted = False | |
def signal_handler(signal, frame): | |
global interrupted | |
interrupted = True | |
def interrupt_callback(): | |
global interrupted | |
return interrupted | |
if len(sys.argv) == 1: | |
print("Error: need to specify model name") | |
print("Usage: python demo.py your.model") | |
sys.exit(-1) | |
model = sys.argv[1] | |
# capture SIGINT signal, e.g., Ctrl+C | |
signal.signal(signal.SIGINT, signal_handler) | |
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5) | |
print('Listening... Press Ctrl+C to exit') | |
# main loop | |
detector.start(detected_callback=snowboydecoder.play_audio_file, | |
interrupt_check=interrupt_callback, | |
sleep_time=0.03) | |
detector.terminate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment