forked from adarshpandey10t/Hacktoberfestmine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriday.py
More file actions
328 lines (250 loc) · 9.54 KB
/
Friday.py
File metadata and controls
328 lines (250 loc) · 9.54 KB
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
from platform import uname
import requests
import pyttsx3
import speech_recognition as sr
import datetime
import time
import os
import winshell
import pywhatkit as kit
from pytube import YouTube
from requests import get
import wikipedia
import webbrowser
import subprocess
import subprocess
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import pyjokes
import ctypes
import time
import requests
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def speak(audio):
engine.say(audio)
print(audio)
engine.runAndWait()
assname = "friday"
def wishMe():
hour = int(datetime.datetime.now().hour)
tt = time.strftime("%I:%M %p")
if hour >= 0 and hour < 12:
speak(f"Good Morning sir!,its {tt} ")
elif hour >= 12 and hour < 17:
speak(f"Good Afternoon sir! its {tt} ")
else:
speak(f"Good Evening sir! its {tt} ")
speak("I am your Assistant")
speak(assname)
def takecommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("listening.....")
r.pause_threshold = 1
audio = r.listen(source, phrase_time_limit=5)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"user said: {query}\n")
except Exception:
return "none"
return query
usname = "none"
def username():
speak("What should i call you sir")
usname = takecommand()
speak("Welcome Mister")
speak(usname)
print("====================")
print("Welcome Mr.", usname)
print("====================")
speak("How can i Help you, Sir")
class location:
res = requests.get('https://ipinfo.io/')
data = res.json()
ip = data['ip']
city = data['city']
region = data['region']
country = data['country']
org = data['org']
postal = data['postal']
timezone = data['timezone']
location = data['loc'].split(',')
latitude = location[0]
longitude = location[1]
def calculate(string):
answer = eval(string)
return answer
if __name__ == "__main__":
clear = lambda: os.system('cls')
clear()
wishMe()
username()
while (True):
query = takecommand().lower()
local = location
# Aplications to run
if "open notepad" in query:
speak("openning notepad sir")
path = "C:\\Windows\\system32\\notepad.exe"
os.startfile(path)
elif "open arduino" in query:
speak("openning arduino sir")
path = "C:\\Program Files (x86)\\Arduino\\arduino.exe"
os.startfile(path)
elif "open command prompt" in query:
speak("openning command prompt sir")
os.system("start cmd")
# Music Video
elif "play music" in query or "jarvis play the music" in query or "play the music" in query or "Jarvis play music" in query:
speak("Yeah sure but what you want to listen sir?")
pp = takecommand().lower()
kit.playonyt(pp)
# Operations
elif "wikipedia" in query:
speak("searching in wikipedia sir....")
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("sir according to wikipedia")
speak(results)
elif "where am i" in query or "location" in query or "where i am" in query:
speak("let me find sir")
speak(f"I guess sir we are in {local.city} city in {local.country}")
speak("Should i find more details")
tt = takecommand().lower()
if "yes" in tt or "yep" in tt or "yeah" in tt:
print("Latitude : ", local.latitude)
print("Longitude : ", local.longitude)
print("IP : ", local.ip)
print("City : ", local.city)
print("Region : ", local.region)
print("Country : ", local.country)
print("Org : ", local.org)
print("Postal : ", local.postal)
print("Timezone : ",local.timezone)
elif "time" in query:
timee = time.strftime("%I:%M %p")
speak(f"Sir its {timee}")
elif "change my name to" in query:
query = query.replace("change my name to", "")
usname = query
speak("Name changed")
elif "change your name" in query:
speak("What would you like to call me, Sir ")
assname = takecommand()
speak("Thanks for naming me")
elif "what's your name" in query or "what is your name" in query:
speak("My friends call me")
speak(assname)
print("My friends call me", assname)
elif 'exit' in query or 'quit' in query:
speak("Thanks for using me")
exit()
elif 'joke' in query:
speak(pyjokes.get_joke())
elif "who i am" in query:
speak("I guess if you talk then definitely you are a human.")
elif "who made you" in query or "who created you" in query:
speak("I was created as a Minor project by Mister Ayush in 2019,, as a attempt to help users who are blind or want to perform task using assistant")
elif 'is love' in query:
speak("It is 7th sense that destroy all other senses")
elif "who are you" in query:
speak("I am your virtual assistant created by Mister, Ayush")
elif "restart" in query:
subprocess.call(["shutdown", "/r"])
elif "hibernate" in query or "sleep" in query:
speak("Hibernating")
subprocess.call("shutdown / h")
elif "log off" in query or "sign out" in query:
speak("Make sure all the application are closed before sign-out")
time.sleep(5)
subprocess.call(["shutdown", "/l"])
elif "write a note" in query:
speak("What should i write, sir")
note = takecommand()
file = open('jarvis.txt', 'w')
speak("Sir, Should i include date and time")
snfm = takecommand()
if 'yes' in snfm or 'sure' in snfm:
strTime =time.strftime("%I:%M %p")
file.write(strTime)
file.write(" :- ")
file.write(note)
else:
file.write(note)
elif "show note" in query:
speak("Showing Notes")
file = open("jarvis.txt", "r")
for lines in file:
speak(lines)
elif 'lock window' in query:
speak("locking the device")
ctypes.windll.user32.LockWorkStation()
elif 'shutdown' in query:
speak("Hold On a Sec ! Your system is on its way to shut down")
subprocess.call('shutdown / p /f')
elif f"{assname}" in query:
speak(f"{assname} in your service Mister")
speak(usname)
elif 'empty recycle bin' in query or 'empty recyclebin' in query:
winshell.recycle_bin().empty(confirm = False, show_progress = False, sound = True)
speak("Recycle Bin Recycled")
elif "don't listen" in query or "stop listening" in query:
speak("for how much time in seconds you want me to stop listening")
try:
a = int(takecommand())
time.sleep(a)
print(a)
except Exception as e:
print("Give time in seconds eg-> 10")
elif "good morning" in query:
speak("A warm" +query)
speak("How are you Mister")
speak(usname)
elif 'fine' in query or "good" in query:
speak("It's good to know that your fine")
elif "will you be my gf" in query:
speak("I'm not sure about that, may be you should give me some time")
elif "how are you" in query:
speak("I'm fine, glad you ask that")
elif "i love you" in query:
speak("not more than i do")
elif "calculate" in query:
speak(" Yeah sure tell the equation")
cal = takecommand()
try:
answer = calculate(cal)
speak("The answer is " + str(answer))
except Exception as e:
print(" Sorry can't understand try again")
elif "youtube" in query:
webbrowser.open_new_tab("www.youtube.com")
elif "news" in query:
speak("showing latest news sir")
webbrowser.open("latest news")
elif "instagram" in query:
speak("sure sir")
webbrowser.open_new_tab("www.instagram.com")
elif "google" in query:
speak("sir, what should i search on google")
num = takecommand().lower()
webbrowser.open(f"{num}")
elif "stackoverflow" in query:
webbrowser.open_new("www.stackoverflow.com")
elif "blogger" in query:
webbrowser.open_new_tab("www.blogger.com")
elif "play" in query:
speak("yeah sure sir")
query = query.replace("youtube", "")
kit.playonyt(query)
elif "ip" in query:
ip = get('https://api.ipify.org').text
speak(f"Your IP address is {ip}")
elif query == "none":
continue