-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdct.py
More file actions
39 lines (25 loc) · 1.02 KB
/
dct.py
File metadata and controls
39 lines (25 loc) · 1.02 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
#this is the code for taking voice input from user and searching that on wiki and responding with the summary from wiki
import wikipedia
import pyttsx3
import speech_recognition as sr
invalid_input = True
while invalid_input :
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening")
r.pause_threshold = 2
audio = r.listen(source)
try:
print("Recognising")
qurey = r.recognize_google(audio, language='en-in')
print(f"user input:{qurey}\n ")
wikipedia.search(r.recognize_google(audio, language='en-in'))
engine = pyttsx3.init()
res=wikipedia.summary(r.recognize_google(audio, language='en-in'))
invalid_input=False
print("According to wikipedia : %s"%res)
engine.say(res)
engine.runAndWait()
except Exception as e:
invalid_input=True
#print("please re Run the program")