-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
408 lines (372 loc) · 15.6 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
import datetime
import json
import os
import smtplib
import webbrowser
from difflib import get_close_matches
import wikipedia
from directory import directory
from mail_list import mail, check_email
from speak import speak, speak_news, takeCommand, command
from email.message import EmailMessage
data = json.load(open('data.json'))
email = EmailMessage()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour >= 0:
if hour < 12:
speak('Good Morning Sir!')
elif hour >= 12:
if hour < 18:
speak('Good Afternoon Sir!')
else:
speak('Good Evening!')
speak('I am, Alexis sir. How may i help you?')
def translate(word):
word = word.lower()
if word in data:
speak('%s means' % word)
print(data[word])
speak(data[word])
elif len(get_close_matches(word, data.keys())) > 0:
x = get_close_matches(word, data.keys())[0]
print(('Did you mean ' + x +
' instead, respond with Yes or No.'))
speak('Did you mean ' + x +
' instead, respond with Yes or No.')
ans = takeCommand().lower()
while ans is None:
speak("We didn't understand your entry.")
speak('Please state yes or no..')
ans = takeCommand().lower()
if 'yes' in ans or 'ok' in ans:
print(data[x])
elif 'no' in ans:
print("Word doesn't exist. Please make sure you spelled it correctly.\n")
speak("Word doesn't exist. Please make sure you spelled it correctly.")
else:
print("Word doesn't exist. Please double check it.")
speak("Word doesn't exist. Please double check it.")
def sendEmail(email):
server = smtplib.SMTP(host='smtp.gmail.com', port=587)
server.ehlo()
server.starttls()
# enter file_path of password stored in text file
file = open('file_path_of_text_file_of_password', 'r')
server.login("sender's_main_id", file.readline())
server.send_message(email)
server.close()
if __name__ == "__main__":
wishMe()
while True:
find = 'empty'
cmd = 'empty'
query = takeCommand().lower()
if 'wikipedia' in query:
while find == 'empty':
speak('What do you want me to search for ?')
find = command(takeCommand())
if find == 'None':
speak("Going back to main program...Continuing")
continue
elif find == 'exit':
exit()
speak('Searching, %s in Wikipedia...' % find)
results = wikipedia.summary(find, sentences=2)
speak('According to Wikipedia')
print(results + '\n')
speak(results)
elif 'open youtube' in query:
site = "https://www.youtube.com/"
while cmd == 'empty':
speak('Should i close the program while opening youtube Sir')
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
speak('opening youtube')
webbrowser.get().open_new_tab(site)
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'open google' in query:
site = "https://www.google.co.in/"
while cmd == 'empty':
speak('Should i close the program while opening google Sir')
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
speak('opening google')
webbrowser.get().open_new_tab(site)
if cmd == 'None':
speak('Going back to main program, Continuing')
continue
elif cmd == 'exit':
exit()
elif 'video song' in query:
# enter the video songs folder path
video_dir = 'video_song_folder_path'
file = directory(video_dir)
if file == 'None':
speak('Going back to main program, Continuing')
continue
elif 'song' in query or 'music' in query:
# enter the songs folder path
song_dir = 'music_folder_path'
file = directory(song_dir)
if file == 'None':
speak('Going back to main program, Continuing')
continue
elif 'movie' in query:
# enter the movies folder path
movie_dir = 'movie_folder_path'
file = directory(movie_dir)
if file == 'None':
speak('Going back to main program, Continuing')
continue
elif 'web series' in query:
# path_syntax = "path\web_series_folder\web_series_particular\web_series_season\web_series_episode"
# example = "D:\Web Series\Sherlock Holmes\Sherlock Holmes S02\Episode-1"
# enter the web series folder path
web_series_folder = 'path\web_series_folder_path' # web_series_path = "D:\Web Series"
file = directory(web_series_folder)
if file == 'None':
speak('Going back to main program, Continuing')
continue
elif 'time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")
elif 'code' in query:
# enter the vs code application path
codePath = 'vs_code_path'
while cmd == 'empty':
speak('Should i close the program while opening VS-Code Sir')
cmd = command(takeCommand())
if cmd == 'exit' or cmd == 'None':
break
else:
cmd = 'empty'
continue
speak('opening VS Code')
os.startfile(codePath)
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
if cmd == 'exit':
exit()
elif 'find on youtube' in query or 'search on youtube' in query:
while find == 'empty':
speak('What do you want me to search for ? ')
find = command(takeCommand())
if find == 'None':
speak('Going back to main program...Continuing')
continue
elif find == 'exit':
exit()
site = 'https://www.youtube.com/results?search_query=' + find
while cmd == 'empty':
speak('Should i close the program while searching %s on youtube Sir' % find)
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
speak('searching %s on youtube' % find)
webbrowser.get().open_new_tab(site)
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'find location' in query or 'search location' in query:
while find == 'empty':
speak('What location should i search for')
find = command(takeCommand())
if find == 'None':
speak('Going back to main program...Continuing')
continue
elif find == 'exit':
exit()
site = 'https://google.co.in/maps/place/' + find + '/&'
cmd = 'empty'
while cmd == 'empty':
speak('Should i close the program while searching %s on google maps Sir' % find)
cmd = command(takeCommand())
if cmd == 'exit' or cmd == 'None':
break
else:
cmd = 'empty'
continue
speak('Here is the location of' + find)
webbrowser.get().open_new_tab(site)
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'search' in query:
while find == 'empty':
speak('What do you want me to search for ?')
find = command(takeCommand())
if find == 'None':
speak('Going back to main program...Continuing')
continue
elif find == 'exit':
exit()
site = 'https://google.com/search?q=' + find
while cmd == 'empty':
speak('Should i close the program while searching %s on google Sir' % find)
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
speak('searching %s on google' % find)
webbrowser.get().open_new_tab(site)
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'mail' in query:
C = 'False'
completed = False
while find == 'empty':
done = False
while C != 'True':
speak('To whom should i send mail...')
find = command(takeCommand())
if find == 'None':
done = True
break
elif find == 'exit':
exit()
C = check_email(find.lower())
if find == 'empty':
continue
elif C == 'False':
speak('Sorry.. The receiver is not in the list..')
continue
if done:
completed = True
break
if completed:
speak("Going back to main program... Continuing")
continue
client, receiver = mail(find)
email['from'] = "Darshil Papalkar"
email['to'] = receiver
speak("What is the subject for email?")
email['subject'] = command(takeCommand())
try:
content = 'empty'
finish = False
while content == 'empty':
speak(f'What should i deliver to {client} ?')
content = command(takeCommand())
email.set_content(content.capitalize() + " .")
sendEmail(email)
speak('Email Has been sent')
except Exception as e:
print(e, "\n")
speak('Sorry Unable to send email at this moment')
elif 'how are you' in query:
speak('I am fine sir, Good to see you back')
elif 'your master' in query:
speak('Darshil, is my master. He created me...')
elif 'your name' in query or 'who are you' in query:
speak('My name is Alexis...')
elif 'stands for' in query:
print(
'Alexis is a given name derived from several saints venerated by the Eastern Orthodox and Roman '
'Catholic churches, including Saint Alexis of Rome. Alexis means "helper, defender".')
speak(
'Alexis is a given name derived from several saints venerated by the Eastern Orthodox and Roman '
'Catholic churches, including Saint Alexis of Rome. Alexis means "helper, defender".')
elif 'github' in query:
while cmd == 'empty':
speak('Should i close the program while opening github Sir')
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
# enter the github link
webbrowser.get().open_new_tab('https://github.com/Darshil-Papalkar')
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'linkedin' in query:
while cmd == 'empty':
speak('Should i close the program while opening linkedin Sir')
cmd = command(takeCommand())
if cmd == 'None' or cmd == 'exit':
break
else:
cmd = 'empty'
continue
# enter linkedin account link
webbrowser.get().open_new_tab('https://www.linkedin.com/in/darshil-papalkar-923016194/')
if cmd == 'None':
speak('Going back to main program...Continuing')
continue
elif cmd == 'exit':
exit()
elif 'dictionary' in query:
while find == 'empty':
speak('What do you want me to search in dictionary ? ')
find = command(takeCommand())
if find == 'None':
speak('Going back to main program...Continuing')
continue
elif find == 'exit':
exit()
translate(find)
elif 'news' in query:
speak('Sure sir...')
speak_news()
elif 'back' in query:
speak('Already in the main program sir')
continue
elif 'exit' in query:
speak("Exiting Program!")
exit()
elif 'what can you do' in query:
print(
' 1. search wikipedia -- to search in wikipedia\n' +
' 2. open youtube -- to open youtube on ms edge\n' +
' 3. open google -- to open google on ms edge\n' +
' 4. email -- to send email \n' +
' 5. play video songs -- to open video song list\n' +
' 6. play web series -- to open webseries folder\n' +
' 7. play movie -- to open movie list\n' +
' 8. play song -- to play songs'
' 9. find on youtube -- to search on youtube\n' +
'10. time -- to display the current time\n' +
'11. search -- to search on ms edge\n' +
'12. find location -- to search the user choice location\n' +
'13. your master -- to know my master\n' +
'14. your name -- to know my name\n' +
"15. stands for -- to know my name's full form\n" +
'16. open code -- to open vs code\n' +
'17. github -- to open the github\n' +
'18. linkedin -- to open linkedin account\n' +
'19. dictionary -- to search for in dictionary\n' +
'20. news -- to seach the current news\n' +
'21. exit -- to exit this program\n'
)
speak('Sir, I can perform tasks stated below')
else:
speak('Cannot recognise the command given...Please speak again..!\n')