-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (39 loc) · 1.12 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
48
49
50
51
52
53
import speech_recognition as sr
import pyttsx3 as tts
import pywhatkit
import datetime
import wikipedia as wikki
listener = sr.Recognizer()
engine = tts.init()
# setting female voice
voices = engine.getProperty("voices")
engine.setProperty('voice', voices[0].id)
def talk(msg):
engine.say(msg)
engine.runAndWait()
def take_user_command():
try:
with sr.Microphone() as source:
print("listening for the input voice...")
voice = listener.listen(source)
command = listener.recognize_google(voice)
if 'alexa' or 'Alexa' in command:
print(command)
except:
print("Got Exception...")
pass
return command
def process_command():
command = take_user_command()
if 'play' or 'song' in command:
pywhatkit.playonyt(command)
elif 'time' or 'Time' in command:
time = datetime.datetime.now().strftime('%H:%M')
print(time)
talk("Current Time is " + time)
elif 'about' in command:
info = wikki.summary(command, 1)
print(info)
talk(info)
while True:
process_command()