-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirt-ass.py
64 lines (52 loc) · 1.51 KB
/
virt-ass.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
54
55
56
57
58
59
60
61
62
63
64
'''
virtual assistant
programming hero youtube
pip install speachrecognition, pyttx3, pyaudio, pywhatkit, wikipedia, pyjokes
'''
import speach_recognition as sr
import pyttx3
import pywhatkit
import datetime
import wikipedia
import pyjokes
listener = sr.Recognizer()
engine = pyttx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def talk(text):
engine.say(text)
engine.runAndWait()
def take_command():
try:
with sr.Microphone as source:
print('Sir, awaiting instruction....')
voice = listener.listen(source)
command = listener.Recognize_google(voice)
command = command.lower()
if 'curie' in command:
command = command.replace('curie')
print(command)
except:
pass
return command
def run_curie():
command = take_command()
print(command)
if 'on youtube play' in command:
ytube = command.replace('on youtube play', '')
talk('Sir, Playing ' + ytube + ' on youtube.')
pywhatkit.playonyt(ytube)
elif 'time' in command:
time = datetime.datetime.now().strftime('%H:%M:%S:%p')# returns hour - minuit - second - and am/pm
talk('Sir, The exact current time is ' + time)
elif 'get info on ' in command:
subject = command.replace('get info on ', '')
info = wikipedia.summary(suject, 5)
print(info)
talk('Sir, wikipedia states ' + info)
elif 'joke' in command:
talk(pyjokes.get_joke())
else:
talk('Sorry Sir, I didnt understand, could you say that again?')
while True:
run_curie()