-
Notifications
You must be signed in to change notification settings - Fork 0
/
mondai.py
340 lines (331 loc) · 11.2 KB
/
mondai.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
import speech_recognition as sr
import time
import subprocess
import webbrowser
import gtts
from playsound import playsound
import os
import sys
def getvars():
file1 = open("pathtospotify.txt", "r")
global spotifypath
spotifypath=file1.read()
print(spotifypath)
getvars()
def mondai():
r = sr.Recognizer()
speech = sr.Microphone()
with speech as source:
print("how can i help you")
tts = gtts.gTTS("hello master")
try:
tts.save("hello.mp3")
except OSError:
pass
playsound("hello.mp3")
audio = r.listen(source)
try:
recog = r.recognize_google(audio, language='en-US')
print(recog)
print("processing...")
speak(recog)
time.sleep(2)
mondai()
except sr.UnknownValueError:
print("sorry i dont understand this")
tts = gtts.gTTS("sorry i dont understand this")
try:
tts.save("dontunderstand.mp3")
except OSError:
pass
playsound("dontunderstand.mp3")
os.remove("dontunderstand.mp3 ")
def speak(recog):
if (recog == "hello"):
print("hello how can i help you")
tts = gtts.gTTS("hello how can i help you")
tts.save("howcanihelp.mp3")
playsound("howcanihelp.mp3")
os.remove("howcanihelp.mp3")
elif (recog == "are you here"):
print("I am always on your side")
tts = gtts.gTTS("I am always on your side")
tts.save("onside.mp3")
playsound("onside.mp3")
os.remove("onside.mp3")
elif (recog == "how are you"):
print("i am fine")
tts = gtts.gTTS("i am fine")
tts.save("fine.mp3")
playsound("fine.mp3")
os.remove("fine.mp3")
elif (recog == "what are you doing today"):
print("i am staying in your computer i think")
tts = gtts.gTTS("i am staying in your computer i think")
tts.save("stayincomputer.mp3")
playsound("stayincomputer.mp3")
os.remove("stayincomputer.mp3")
elif (recog == "do you sing"):
print("no")
tts = gtts.gTTS("no")
tts.save("no.mp3")
playsound("no.mp3")
os.remove("no.mp3")
elif (recog == "shut up"):
print("ok")
tts = gtts.gTTS("shut up")
tts.save("shutup.mp3")
playsound("shutup.mp3")
os.remove("shutup.mp3")
elif (recog == "can you cook"):
print("i can help you with that probably")
tts = gtts.gTTS("i can help you with that probably")
tts.save("help.mp3")
playsound("help.mp3")
os.remove("help.mp3")
elif (recog == "do you like me"):
print("probably")
tts = gtts.gTTS("probably")
tts.save("probably.mp3")
playsound("probably.mp3")
os.remove("probably.mp3")
elif (recog == "what's on"):
print("right now nothing")
tts = gtts.gTTS("right now nothing")
tts.save("nothing.mp3")
playsound("nothing.mp3")
os.remove("nothing.mp3")
elif (recog == "mistake"):
print("alright")
tts = gtts.gTTS("alright")
tts.save("alright.mp3")
playsound("alright.mp3")
os.remove("alright.mp3")
elif (recog == "what is now"):
print("what do you mean by that")
tts = gtts.gTTS("what do you mean by that")
tts.save("mean.mp3")
playsound("mean.mp3")
os.remove("mean.mp3")
elif (recog == "what are you doing"):
print("i am doing nothing right now")
tts = gtts.gTTS("i am doing nothing right now")
tts.save("doingnothing.mp3")
playsound("doingnothing.mp3")
os.remove("doingnothin.mp3")
elif (recog == "could you help me"):
print("i would like to help you")
tts = gtts.gTTS("i would like to help you")
tts.save("liketohelp.mp3")
playsound("liketohelp.mp3")
os.remove("liketohelp.mp3")
elif (recog == "you can do nothing for me"):
print("i understood")
tts = gtts.gTTS("i understood")
tts.save("understood.mp3")
playsound("understood.mp3")
os.remove("understood.mp3")
elif (recog == "are you helping me now"):
print("how can i help you")
tts = gtts.gTTS("how can i help you")
tts.save("howcanihelp.mp3")
playsound("howcanihelp.mp3")
os.remove("howcanihelp.mp3")
elif (recog == "do something"):
print("what should i do")
tts = gtts.gTTS("what should i do")
tts.save("whatshouldido.mp3")
playsound("whatshouldido.mp3")
os.remove("whatshouldido.mp3")
elif (recog == "who created you"):
print("i am created by LP")
tts = gtts.gTTS("i am created by LP")
tts.save("created.mp3")
playsound("created.mp3")
os.remove("created.mp3")
elif (recog == "exit"):
print("i am exiting you world")
tts = gtts.gTTS("i am leaving")
tts.save("leaving.mp3")
playsound("leaving.mp3")
os.remove("leaving.mp3")
sys.exit()
elif (recog == "thanks"):
print("i understand")
tts = gtts.gTTS("i unterstand")
tts.save("understand.mp3")
playsound("understand.mp3")
os.remove("understand.mp3")
start()
else:
functions(recog)
def functions(recog):
print("functions processing")
if (recog == "what's the weather like"):
print("this is the Weather")
tts = gtts.gTTS("this is the Weather")
tts.save("wheater.mp3")
playsound("wheater.mp3")
webbrowser.open("https://www.wetter.com/deutschland/EUDE.html")
os.remove("wheater.mp3")
elif (recog == "open Instagram"):
print("open instagram")
tts = gtts.gTTS("open instagram")
tts.save("instagram.mp3")
playsound("instagram.mp3")
webbrowser.open_new_tab("https://instagram.com")
os.remove("instagram.mp3")
elif (recog == "open Spotify"):
print("open spotify")
tts = gtts.gTTS("open Spotify")
tts.save("spotify.mp3")
playsound("spotify.mp3")
os.system(spotifypath)
os.remove("spotify.mp3")
elif (recog == "open YouTube"):
print("open youtube")
tts = gtts.gTTS("open Youtube")
tts.save("youtube.mp3")
playsound("youtube.mp3")
webbrowser.open_new_tab("https://youtube.com")
os.remove("youtube.mp3")
elif (recog == "open Facebook"):
print("open Facebook")
tts = gtts.gTTS("open Facebook")
tts.save("facebook.mp3")
playsound("facebook.mp3")
webbrowser.open_new_tab("https://facebook.com")
os.remove("facebook.mp3")
elif (recog == "I want to print something"):
print("here are a few ideas")
tts = gtts.gTTS("here are a few ideas")
tts.save("ideasprint.mp3")
playsound("ideasprint.mp3")
webbrowser.open_new_tab("https://www.thingiverse.com")
os.remove("ideasprint.mp3")
elif (recog == "open Google"):
print("open Google")
tts = gtts.gTTS("open Google")
tts.save("google.mp3")
playsound("google.mp3")
webbrowser.open_new_tab("https://google.com")
os.remove("google.mp3")
elif (recog == "open stack overflow"):
print("open stackoverflow")
tts = gtts.gTTS("open stack overflow")
tts.save("overflow.mp3")
playsound("overflow.mp3")
webbrowser.open_new_tab("https://stackoverflow.com")
os.remove("overflow.mp3")
elif (recog == "open wikipedia"):
print("open Wikipedia")
tts = gtts.gTTS("open wikipedia")
tts.save("wikipedia.mp3")
playsound("wikipedia.mp3")
webbrowser.open("https://wikipedia.org")
os.remove("wikipedia.mp3")
elif (recog == "new tab"):
print("open new tab")
tts = gtts.gTTS("open new tab")
tts.save("tab.mp3")
playsound("tab.mp3")
webbrowser.open("https://google.com")
os.remove("tab.mp3")
elif (recog == "new tap"):
print("open new tab")
tts = gtts.gTTS("open new tab")
tts.save("tab.mp3")
playsound("tab.mp3")
webbrowser.open("https://google.com")
os.remove("tab.mp3")
elif (recog == "new top"):
print("open new tab")
tts = gtts.gTTS("open new tab")
tts.save("tab.mp3")
playsound("tab.mp3")
webbrowser.open("https://google.com")
os.remove("tab.mp3")
elif (recog == "open Wikipedia"):
print("open Wikipedia")
tts = gtts.gTTS("open wikipedia")
tts.save("wikipedia.mp3")
playsound("wikipedia.mp3")
webbrowser.open("https://wikipedia.org")
os.remove("wikipedia.mp3")
else:
print("I dont understand this")
def start():
print("If you need me only say my Name")
print("I am called Mondi")
r = sr.Recognizer()
speech = sr.Microphone()
while True:
with speech as source:
audio = r.listen(source)
try:
recog = r.recognize_google(audio, language = 'en-US')
print(recog)
if (recog == "Mondi"):
print("starting...")
mondai()
start()
if (recog == "Monti"):
print("starting...")
mondai()
start()
if (recog == "Modi"):
print("starting...")
mondai()
start()
if (recog == "Monty" ):
print("starting...")
mondai()
start()
if (recog == "Monday" ):
print("starting...")
mondai()
start()
if (recog == "Monday Monday" ):
print("starting...")
mondai()
start()
if (recog == "Monday Monday Monday" ):
print("starting...")
mondai()
start()
if (recog == "1D" ):
print("starting...")
mondai()
start()
if (recog == "mondi" ):
print("starting...")
mondai()
start()
if (recog == "Mondeo" ):
print("starting...")
mondai()
start()
if (recog == "bungie" ):
print("starting...")
mondai()
start()
if (recog == "deep" ):
print("starting...")
mondai()
start()
if (recog == "one day" ):
print("starting...")
mondai()
start()
if (recog == "Sunday" ):
print("starting...")
mondai()
start()
if (recog == "mundane" ):
print("starting...")
mondai()
start()
except sr.UnknownValueError:
print("try again")
start()
start()