-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempCodeRunnerFile.py
46 lines (35 loc) · 1.15 KB
/
tempCodeRunnerFile.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
import speech_recognition as sr
import pyttsx3
import wikipedia
import pywhatkit
listener = sr.Recognizer()
player = pyttsx3.init()
def listen():
with sr.Microphone() as input_device:
print("I am ready, Listening ....")
voice_content = listener.listen(input_device)
text_command = listener.recognize_google(voice_content)
text_command = text_command.lower()
print(text_command)
return text_command;
def talk(text):
player.say(text)
player.runAndWait()
def run_voice_bot():
command = listen()
if "sunny" in command:
command = command.replace("sunny","")
if "what is" in command:
command = command.replace("what is", "")
info = wikipedia.summary(command, 5)
talk(info)
elif "who is" in command:
command = command.replace("who is", "")
info = wikipedia.summary(command, 5)
talk(info)
elif "play" in command:
command = command.replace("play", "")
pywhatkit.playonyt(command)
else:
talk("Sorry, I am unable to find what you looking for")
run_voice_bot()