-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxiaoR1.py
51 lines (32 loc) · 976 Bytes
/
xiaoR1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
sys.path.append('./snowboy')
import snowboydecoder
import signal
from main import main
interrupted = False
def signal_handler():
global interrupted
if (interrupted == True):
interrupted = False
else:
interrupted = True
def interrupt_callback():
global interrupted
return interrupted
def wake_up():
model = "snowboy/小R.pmdl"
# 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=signal_handler,
interrupt_check=interrupt_callback,
sleep_time=0.03)
detector.terminate()
while True:
print("----------------------------对话机器人-----------------------------------")
wake_up()
snowboydecoder.play_audio_file()
main()
signal_handler()