forked from jasperproject/jasper-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·45 lines (30 loc) · 1.12 KB
/
manage.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
#!/usr/bin/env python
import sys
import os
import logging
import requests
# Include folder with ./manage.py as module.
sys.path.insert(1, os.path.join(os.path.dirname(__file__)))
from otto.contrib.mic.pyaudio import mic
from otto.contrib.transcribe.sphinx import PocketSphinxSTT
from otto.contrib.transcribe.wit import WitSTT
from otto.listen import Listener
logging.basicConfig(level=logging.DEBUG)
if __name__ == '__main__':
listener = Listener(mic=mic)
ps = PocketSphinxSTT()
wit = WitSTT()
while True:
onset_frames = listener.get_disturbance()
onset = ps.transcribe(onset_frames)
print "Onset", onset
if 'computer' in onset.lower():
phrase_frames = listener.get_phrase()
phrase = wit.transcribe(phrase_frames)
logging.info('Heard "%s"', phrase)
if 'on' in phrase:
requests.get('https://agent.electricimp.com/QhaVzh5W-sFT?light_state=1')
elif 'off' in phrase:
requests.get('https://agent.electricimp.com/QhaVzh5W-sFT?light_state=0')
if 'exit' in phrase:
exit()