demo.py
Go to the documentation of this file.
1 import snowboydecoder
2 import sys
3 import signal
4 
5 interrupted = False
6 
7 
8 def signal_handler(signal, frame):
9  global interrupted
10  interrupted = True
11 
12 
14  global interrupted
15  return interrupted
16 
17 if len(sys.argv) == 1:
18  print("Error: need to specify model name")
19  print("Usage: python demo.py your.model")
20  sys.exit(-1)
21 
22 model = sys.argv[1]
23 
24 # capture SIGINT signal, e.g., Ctrl+C
25 signal.signal(signal.SIGINT, signal_handler)
26 
27 detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
28 print('Listening... Press Ctrl+C to exit')
29 
30 # main loop
31 detector.start(detected_callback=snowboydecoder.play_audio_file,
32  interrupt_check=interrupt_callback,
33  sleep_time=0.03)
34 
35 detector.terminate()
def signal_handler(signal, frame)
Definition: demo.py:8
def interrupt_callback()
Definition: demo.py:13


dialogflow_ros
Author(s): Anas Abou Allaban
autogenerated on Mon Jun 10 2019 13:02:59