-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (38 loc) · 1.09 KB
/
main.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
import speech_recognition as sr
import pyttsx3
import wikipedia
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def talk(text):
engine.say(text)
engine.runAndWait()
def take_command():
try:
with sr.Microphone() as source:
print('Listening...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'CelebExp' in command:
command = command.replace('CelebExp', '')
print(command)
except:
pass
return command
def run_CelebExp():
command = take_command()
print(command)
if 'who is' in command:
person = command.replace('who the is', '')
info = wikipedia.summary(person, 1)
print(info)
talk(info)
elif 'bye' in command:
talk("Ok then, see you later")
print("Ok then, see you later")
else:
talk("I didn't get that clearly, please repeat it")
while True:
run_CelebExp()