-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathe2.ns_kws.py
More file actions
42 lines (28 loc) · 874 Bytes
/
e2.ns_kws.py
File metadata and controls
42 lines (28 loc) · 874 Bytes
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
"""
A example to show Noise Suppression (NS) and Keyword Spotting (KWS)
The keyword is "computer".
Requirements:
snowboy - https://github.com/Kitt-AI/snowboy
python-webrtc-audio-processing - pip3 install webrtc-audio-processing
"""
import time
from voice_engine.source import Source
from voice_engine.kws import KWS
from voice_engine.ns import NS
def main():
src = Source(rate=16000, channels=1, device_name="default")
ns = NS(rate=16000, channels=1)
kws = KWS(model='computer', sensitivity=0.6, verbose=True)
src.pipeline(ns, kws)
def on_detected(keyword):
print('\ndetected {}'.format(keyword))
kws.set_callback(on_detected)
src.pipeline_start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
break
src.pipeline_stop()
if __name__ == '__main__':
main()