-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvision.py
236 lines (187 loc) · 8.46 KB
/
vision.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import pyttsx3
import os
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import smtplib
import googlesearch
import bs4 as bs
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning Ashish")
elif hour>=12 and hour<18:
speak("Good Evening Ashish")
else:
speak("Good Afternoon Ashish")
speak("I am vision and this is my partner natasha. Please tell how may we help you?")
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pausethreshhold = 1
audio = r.listen(source)
try:
print("Recognising....")
query = r.recognize_google(audio, language='en-in')
print(f"You said: {query}\n")
except Exception as e:
print(e)
print("Say that again please...")
return "None"
return query
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login('[email protected]', 'ay11rm11')
server.sendmail('[email protected]', to, content)
server.close()
if __name__ == "__main__":
wishMe()
while True:
query = takeCommand().lower()
if 'vision' in query:
engine.setProperty('voice', voices[0].id)
if 'in wikipedia' in query:
speak("Searching Wikipedia...")
query = query.replace("wikipedia", "")
query=query.replace('vision search', '')
query=query.replace('in',"")
Results = wikipedia.summary(query, sentences=1)
speak("According to Wikipedia ")
print(Results)
speak(Results)
elif 'open youtube' in query:
webbrowser.open("youtube.com")
elif 'open google' in query:
webbrowser.open("google.com")
elif 'open stackoverflow' in query:
webbrowser.open("stackoverflow.com")
elif 'open my website' in query:
webbrowser.open("ashtheaibot.000webhostapp.com")
elif 'play music' in query:
music_dir = 'D:\\Music'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
print(f"The time Sir is {strTime}")
speak(f"The time Sir is {strTime}")
elif 'open vs code' in query:
codePath = "C:\\Users\\Ashish Yadav\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
os.startfile(codePath)
elif 'open chrome' in query:
charmPath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
os.startfile(charmPath)
elif 'play movie' in query:
moviePath = "D:\\Chak De India 2007 Hindi Www.MoviesBay.in 480p BluRay 450MB.mkv"
os.startfile(moviePath)
elif 'play fifa' in query:
gamePath = "D:\\FIFA 2K18\\FIFA18.exe"
os.startfile(gamePath)
elif 'mail to daddy' in query:
try:
speak('what should i say?')
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak('email has been sent')
except Exception as e:
print(e)
speak("Something went wrong, so sorry")
elif 'mail to bhaiya' in query:
try:
speak('what should i say?')
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak('email has been sent')
except Exception as e:
print(e)
speak("Something went wrong, so sorry")
elif 'tell me about you' in query:
speak('My name as you know is Vision. I am an android with the mind of JARVIS the personnal AI of tony stark, i had a vibranium body made from Ultron currently in posession of the U S government')
elif 'quit' in query:
speak("Goodbye Sir!!")
exit()
elif 'natasha' in query:
engine.setProperty('voice', voices[1].id)
if 'in wikipedia' in query:
speak("Searching Wikipedia...")
query = query.replace("wikipedia", "")
query=query.replace('natasha search', '')
query=query.replace('in',"")
Results = wikipedia.summary(query, sentences=1)
speak("According to Wikipedia ")
print(Results)
speak(Results)
elif 'open youtube' in query:
webbrowser.open("youtube.com")
elif 'open google' in query:
webbrowser.open("google.com")
elif 'open stackoverflow' in query:
webbrowser.open("stackoverflow.com")
elif 'open my website' in query:
speak("Uhhhh...I don't have the permission to access that site. Do you want me to call vision for this Sir?")
webcom = takeCommand()
if 'yes' in webcom:
engine.setProperty('voice', voices[0].id)
speak("I presume its your website that natasha needs help with!, here it is")
webbrowser.open('ashtheaibot.000webhostapp.com')
speak('Natasha I am done')
engine.setProperty('voice', voices[1].id)
speak('Thanks for the help')
elif 'play music' in query:
music_dir = 'D:\\Music'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
print(f"The time Sir is {strTime}")
speak(f"The time Sir is {strTime}")
elif 'open vs code' in query:
codePath = "C:\\Users\\Ashish Yadav\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
os.startfile(codePath)
elif 'open chrome' in query:
charmPath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
os.startfile(charmPath)
elif 'play movie' in query:
moviePath = "D:\\Chak De India 2007 Hindi Www.MoviesBay.in 480p BluRay 450MB.mkv"
os.startfile(moviePath)
elif 'play fifa' in query:
gamePath = "D:\\FIFA 2K18\\FIFA18.exe"
os.startfile(gamePath)
elif 'mail to daddy' in query:
try:
speak('what should i say?')
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak('email has been sent')
except Exception as e:
print(e)
speak("Something went wrong, so sorry")
elif 'mail to bhaiya' in query:
try:
speak('what should i say?')
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak('email has been sent')
except Exception as e:
print(e)
speak("Something went wrong, so sorry")
elif 'tell me about you' in query:
speak('My name as you know is Natasha. I am a natural language user interface build by Aashish Yaaadav. Right i am only trained to do basic stuffs only.....but hey i evolve.')
elif 'quit' in query:
speak('Goodbye Sir!!')
exit()