File tree Expand file tree Collapse file tree 5 files changed +54
-20
lines changed Expand file tree Collapse file tree 5 files changed +54
-20
lines changed Original file line number Diff line number Diff line change 88
88
89
89
# Rope project settings
90
90
.ropeproject
91
+ * .wav
Original file line number Diff line number Diff line change @@ -13,27 +13,20 @@ It uses [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) for keyword sp
13
13
import time
14
14
from threading import Thread, Event
15
15
16
- import pyaudio
17
- from respeaker import Microphone, Player
18
-
19
-
20
- mic = None
16
+ import fix_import
17
+ from respeaker import Microphone
21
18
22
19
23
20
def task(quit_event):
24
- global mic
21
+ mic = Microphone(quit_event=quit_event)
25
22
26
- pa = pyaudio.PyAudio()
27
- mic = Microphone(pa)
28
23
while not quit_event.is_set():
29
- if mic.wakeup(keyword='alexa '):
24
+ if mic.wakeup('respeaker '):
30
25
print('Wake up')
31
26
data = mic.listen()
32
27
text = mic.recognize(data)
33
- if text.find('play music') >= 0:
34
- print('Play music')
35
-
36
- mic.close()
28
+ if text:
29
+ print('Recognized %s' % text)
37
30
38
31
39
32
def main():
@@ -44,14 +37,11 @@ def main():
44
37
try:
45
38
time.sleep(1)
46
39
except KeyboardInterrupt:
47
- print('\nquit ')
40
+ print('Quit ')
48
41
quit_event.set()
49
- mic.quit()
50
42
break
51
-
52
43
thread.join()
53
44
54
-
55
45
if __name__ == '__main__':
56
46
main()
57
- ```
47
+ ```
Original file line number Diff line number Diff line change
1
+ `ReSpeaker <http://respeaker.io >`_ is an open project to create voice enabled objects.
2
+ ReSpeaker python library is an open source python library to provide basic functions of voice interaction.
3
+
4
+ It uses `PocketSphinx <https://github.com/cmusphinx/pocketsphinx >`_ for keyword spotting
5
+ and uses `webrtcvad <https://github.com/wiseman/py-webrtcvad >`_ for voice activity detecting.
6
+
7
+
8
+ * Getting started
9
+
10
+ import time
11
+ from threading import Thread, Event
12
+
13
+ import fix_import
14
+ from respeaker import Microphone
15
+
16
+
17
+ def task(quit_event):
18
+ mic = Microphone(quit_event=quit_event)
19
+
20
+ while not quit_event.is_set():
21
+ if mic.wakeup('respeaker'):
22
+ print('Wake up')
23
+ data = mic.listen()
24
+ text = mic.recognize(data)
25
+ if text:
26
+ print('Recognized %s' % text)
27
+
28
+
29
+ def main():
30
+ quit_event = Event()
31
+ thread = Thread(target=task, args=(quit_event,))
32
+ thread.start()
33
+ while True:
34
+ try:
35
+ time.sleep(1)
36
+ except KeyboardInterrupt:
37
+ print('Quit')
38
+ quit_event.set()
39
+ break
40
+ thread.join()
41
+
42
+ if __name__ == '__main__':
43
+ main()
Original file line number Diff line number Diff line change 1
1
[metadata]
2
- description-file = README.md
2
+ description-file = README.rst
Original file line number Diff line number Diff line change 24
24
# Versions should comply with PEP440. For a discussion on single-sourcing
25
25
# the version across setup.py and the project code, see
26
26
# https://packaging.python.org/en/latest/single_source_version.html
27
- version = '0.2 .0' ,
27
+ version = '0.3 .0' ,
28
28
29
29
description = 'To build voice enabled objects with ReSpeaker' ,
30
30
You can’t perform that action at this time.
0 commit comments