-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjam-ai.py
More file actions
72 lines (48 loc) · 1.22 KB
/
jam-ai.py
File metadata and controls
72 lines (48 loc) · 1.22 KB
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
from loklib import listen
from loklib import speech_senth as ss
from loklib import gn_task
def observe(t=5):
res = ""
try:
pmt = listen.out(6)
pmt=pmt.lower()
print("observed : ",pmt)
if "stop" in pmt.lower():
listen.close_audio()
print("stopped")
# remove audio files
gn_task.rm_fld("audio")
ss.say("bye")
res = "stop"
elif "jam" in pmt :
res = "jam"
except Exception as e:
listen.close_audio()
print(f"exception occurred : {e}")
return res
def listen():
while True:
ss.say("listening")
pmt = listen.out(6)
if "stop" in pmt.lower():
break
print("cmd : ",pmt)
res = f"listned : {pmt}"
print("jam : ",res)
ss.say(str(res))
def start():
print("observing")
while True:
ob =observe(4)
if ob == "jam":
listen()
elif ob == "stop":
break
def jam():
try:
start()
except Exception as e:
listen.close_audio()
print(f"exception occurred : {e}")
if __name__ == '__main__':
jam()