-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_sentense.py
executable file
·72 lines (53 loc) · 1.82 KB
/
get_sentense.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
#!/usr/bin/python3
import sys
import traceback
import time
import logging
from julius import Julius
from config_entry import ConfigEntry
from run_cmd import RunCmd
from cmd_converter import CmdConverter
def configure_logging():
l = logging.getLogger() # 'name of class'
l.setLevel(logging.WARNING)
# create console handler and set level to debug
ch = logging.StreamHandler()
# ch.setLevel(logging.INFO)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
l.addHandler(ch)
config = [ConfigEntry('take_pic', ['take make', 'picture photo'], RunCmd('echo "take_pic"')),
ConfigEntry('enable_baby', ['enable', 'baby surveillance'], RunCmd('touch "/tmp/enable_baby"')),
ConfigEntry('disable_baby', ['disable', 'baby surveillance'], RunCmd('rm "/tmp/enable_baby"'))]
def main():
configure_logging()
# start julius
jul = RunCmd('export ALSADEV="dsnooped2"; ./julius_install/bin/julius -C babycamera.jconf -input alsa -module')
jul.execute()
time.sleep(5)
if jul.task_running_:
print("julisus started!")
else:
print("failed to start julius")
sys.exit(1)
x = Julius()
cmd_cnv = CmdConverter(config, 'computer')
try:
while 1:
s = x.getJuliusDetection()
c = cmd_cnv.extractCommand(s)
if c is not None:
print('detected cfg: {}'.format(c.getName()))
c.getExecutable().execute()
time.sleep(0.1)
except KeyboardInterrupt:
print('Exiting...')
except Exception:
print('Exception occured!')
traceback.print_exc(file=sys.stdout)
sys.exit(0)
if __name__ == "__main__":
main()