-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersonal_ass.py
86 lines (64 loc) · 1.95 KB
/
personal_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
65
66
67
68
69
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
#import wikipedia
import pyjokes
def talke(speech):
engine.say(speech)
engine.runAndWait()
listener = sr.Recognizer()
engine= pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
talke('hello Rahul')
talke('I am jerry')
talke('How can I help you')
def command_back():
try:
with sr.Microphone() as source:
print('listening.....')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'jerry' in command:
command = command.replace('jerry','')
print(command)
except:
pass
return command
def run_jerry():
command = command_back()
print(command)
if 'play' in command:
play = command.replace('play','')
talke('playing' + play)
pywhatkit.playonyt(play)
elif 'time' in command:
time = datetime.datetime.now().strftime('%I:%M %p')
talke(time)
print('current time is' + time)
elif 'what is the date today' in command:
date = datetime.datetime.now().strftime('%d-%B-%Y')
talke(date)
print("Today is:" + date)
elif 'date' in command:
talke("sorry, i have lot of things to do")
elif 'are you single' in command:
talke("i am in relationship with your laptop")
elif 'joke' in command:
joke=pyjokes.get_joke()
print(joke)
talke(joke)
elif 'who' or 'what' in command:
print('searching.........')
search = command.replace('who is' or 'what is','')
# talke(pywhatkit.info("Google",lines = 5))
# res= wikipedia.summary(search,5)
# print(res)
# talke(res)
pywhatkit.search(search)
else:
pywhatkit.search(command)
while True:
run_jerry()