-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_module.py
More file actions
37 lines (30 loc) · 818 Bytes
/
input_module.py
File metadata and controls
37 lines (30 loc) · 818 Bytes
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
import speech_recognition as sr
from internet import internet_access
def TakeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
msg = ': Listening....'
print(msg, end='')
print('\b' * len(msg), end='', flush=True)
r.pause_threshold = 1
audio = r.listen(source)
try:
msg2 = ': Recognizing...'
print(msg2, end='')
print('\b' * len(msg2), end='', flush=True)
query = r.recognize_google(audio,language='en-in')
print(f"Me: {query}", end ='')
print((' '*(12-len(query))))
except:
return ""
return query.lower()
def take_input():
"""
Takes user input
"""
if internet_access():
return TakeCommand()
else:
print()
i = input("Me:")
return i