-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvc.py
45 lines (35 loc) · 900 Bytes
/
vc.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
import speech_recognition as sr
import pyttsx3
import calc
def talk():
with sr.Microphone() as source:
msg = "what is your query?"
engine.say(msg)
engine.runAndWait()
print(msg)
print("please speak now")
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
convert(audio)
def convert(audio):
try:
text = r.recognize_google(audio)
print("test1")
ans = calc.calc(text)
print("test2")
print(ans)
reply(ans, text)
except:
msg = "Sorry, we did not get please try again"
# engine.say(msg)
print(msg)
# engine.runAndWait()
def reply(ans, text):
msg="The answer for your query"+text+" is "+ans
engine.say(msg)
print("reply")
print(msg)
engine.runAndWait()
r = sr.Recognizer()
engine = pyttsx3.init()
talk()