-
Notifications
You must be signed in to change notification settings - Fork 37
/
test_inference.py
executable file
·89 lines (76 loc) · 2.07 KB
/
test_inference.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
from eff_word_net.streams import SimpleMicStream
from eff_word_net.engine import HotwordDetector, MultiHotwordDetector
from eff_word_net.audio_processing import Resnet50_Arc_loss
from eff_word_net import samples_loc
base_model = Resnet50_Arc_loss()
mycroft_hw = HotwordDetector(
hotword="mycroft",
model = base_model,
reference_file="mycroft_ref.json",
threshold=0.7,
relaxation_time=2
)
alexa_hw = HotwordDetector(
hotword="alexa",
model=base_model,
reference_file = "alexa_ref.json",
threshold=0.7,
relaxation_time=2,
#verbose=True
)
balloon_hw = HotwordDetector(
hotword="balloon",
model=base_model,
reference_file="balloon_ref.json",
threshold=0.65,
relaxation_time=2,
#verbose=True
)
computer_hw = HotwordDetector(
hotword="computer",
model=base_model,
reference_file="computer_ref.json",
threshold=0.7,
relaxation_time=2,
#verbose=True
)
mobile_hw = HotwordDetector(
hotword="mobile",
model = base_model,
reference_file="mobile_ref.json",
threshold=0.7,
relaxation_time=2,
#verbose=True
)
lights_on = HotwordDetector(
hotword="lights_on",
model = base_model,
reference_file="lights_on_ref.json",
threshold=0.7,
relaxation_time=2
)
lights_off = HotwordDetector(
hotword="lights_on",
model = base_model,
reference_file="lights_off_ref.json",
threshold=0.7,
relaxation_time=2
)
multi_hotword_detector = MultiHotwordDetector(
[mycroft_hw, alexa_hw, balloon_hw, computer_hw, mobile_hw, lights_on, lights_off],
model=base_model,
continuous=True,
)
mic_stream = SimpleMicStream(
window_length_secs=1.5,
sliding_window_secs=0.75
)
mic_stream.start_stream()
#print("Say ", mycroft_hw.hotword)
print("Say one hotword among :", " ".join([x.hotword for x in multi_hotword_detector.detector_collection]))
while True :
frame = mic_stream.getFrame()
best_match = multi_hotword_detector.findBestMatch(frame)
if best_match[0]!=None :
print(best_match[0].hotword, best_match[1])