forked from Melissa-AI/Melissa-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (23 loc) · 783 Bytes
/
main.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
import signal
import subprocess
# Melissa
from melissa import profile
from melissa.utilities import snowboydecoder
interrupted = False
subprocess.call(['python', 'start.py'])
def signal_handler(signal, frame):
global interrupted
interrupted = True
def interrupt_callback():
global interrupted
return interrupted
def melissa_activate():
subprocess.call(['python', 'start.py'])
model = 'data/snowboy_resources/Melissa.pmdl'
signal.signal(signal.SIGINT, signal_handler)
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
if profile.data['hotword_detection'] == 'on':
detector.start(detected_callback=melissa_activate,
interrupt_check=interrupt_callback,
sleep_time=0.03)
detector.terminate()