Skip to content

Commit 99975f8

Browse files
author
Yihui Xiong
committed
v0.3.0
1 parent a289f2f commit 99975f8

File tree

5 files changed

+54
-20
lines changed

5 files changed

+54
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ ENV/
8888

8989
# Rope project settings
9090
.ropeproject
91+
*.wav

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,20 @@ It uses [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) for keyword sp
1313
import time
1414
from threading import Thread, Event
1515
16-
import pyaudio
17-
from respeaker import Microphone, Player
18-
19-
20-
mic = None
16+
import fix_import
17+
from respeaker import Microphone
2118
2219
2320
def task(quit_event):
24-
global mic
21+
mic = Microphone(quit_event=quit_event)
2522
26-
pa = pyaudio.PyAudio()
27-
mic = Microphone(pa)
2823
while not quit_event.is_set():
29-
if mic.wakeup(keyword='alexa'):
24+
if mic.wakeup('respeaker'):
3025
print('Wake up')
3126
data = mic.listen()
3227
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)
3730
3831
3932
def main():
@@ -44,14 +37,11 @@ def main():
4437
try:
4538
time.sleep(1)
4639
except KeyboardInterrupt:
47-
print('\nquit')
40+
print('Quit')
4841
quit_event.set()
49-
mic.quit()
5042
break
51-
5243
thread.join()
5344
54-
5545
if __name__ == '__main__':
5646
main()
57-
```
47+
```

README.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[metadata]
2-
description-file = README.md
2+
description-file = README.rst

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# Versions should comply with PEP440. For a discussion on single-sourcing
2525
# the version across setup.py and the project code, see
2626
# https://packaging.python.org/en/latest/single_source_version.html
27-
version='0.2.0',
27+
version='0.3.0',
2828

2929
description='To build voice enabled objects with ReSpeaker',
3030

0 commit comments

Comments
 (0)