-
Notifications
You must be signed in to change notification settings - Fork 1
/
s2t.py
70 lines (61 loc) · 1.58 KB
/
s2t.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
# coding: utf-8
import speech_recognition as sr
import pyttsx3 as pyttsx
headers = {'''user-agent':'Chrome/53.0.2785.143'''}
#speak=wicl.Dispatch("SAPI.SpVoice")
speak = pyttsx.init()
#async def utlisCheck(check):
def cont(text=None):
if text:
events(text[1],text[2:])
else:
r=sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source)
audio=r.listen(source)
try:
x = r.recognize_google(audio)
print(x)
x=x.lower()
link=x.split()
if check.Fuck_internetCheck is 0:
threading.Thread(target=req(x)).start()
else:
threading.Thread(target=events(x,link)).start()
except:
notify("Sorry Boss, Try again!")
cont()
if __name__=="__main__":
# check = ctypes.CDLL(os.path.dirname(os.path.realpath(__file__))+'/lib/cpp/libint.so')
# asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
# loop=asyncio.get_event_loop()
# for signame in ('SIGINT','SIGTERM'):
# loop.add_signal_handler(getattr(signal,signame),lambda: asyncio.ensure_future(ask_exit(signame)))
while True:
r=sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source,duration=1)
print("Say Something")
audio=r.listen(source,timeout=10, phrase_time_limit=5)
try:
x = r.recognize_google(audio)
x=x.lower()
threading.Thread(target=req(x)).start()
except:
print("No audio detected")
'''
try:
print("Running")
loop.run_forever()
finally:
loop.close()
if x=="jarvis" and first is 0:
speak.say("Yes Boss")
speak.runAndWait()
x=x.split()
text=x[1:]
first=first+1
cont()
else:
threading.Thread(target=req(x)).start()
'''