-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjarvis.py
276 lines (194 loc) · 7.03 KB
/
jarvis.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
from tkinter import *
from PIL import ImageTk
import sys
import time
from tkinter import ttk
import pyttsx3
import os
import datetime as dt
import speech_recognition as sr
import webbrowser
root=Tk()
#root.configure(bg="red")
root.maxsize(width=720,height=415)
root.minsize(width=720,height=415)
root.title("JARVICE")
#root.iconbitmap("calculator.ico")
bg_image=ImageTk.PhotoImage(file='background1.png')
f_image=ImageTk.PhotoImage(file='frame.png')
#..................................jarvis functions......................
engine = pyttsx3.init()
def times():
Time=time.strftime("%H:%M:%S")
engine.say(Time)
def date():
date = dt.datetime.now()
format_date = f"{date:%a, %b %d %Y}"
engine.say(format_date)
hour=dt.datetime.now().hour
data=[]
def Commands():
r =sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
listen="Jarvis Listening...."
ce_label.config(text=listen)
r.pause_threshold = 1
audio = r.listen(source)
try:
print("recognize....")
re=("Jarvis recognize...")
ce1_label.config(text=re)
query = r.recognize_google(audio, language='en-in')
ce2_label.config(text="Sir Command is:"+query)
del data[0:1]
data.append(query)
print(data)
if "hello" in data:
hihello()
if "hi" in data:
hihello()
if "hai" in data:
hihello()
if "open Microsoft Office" in data:
msoffice()
if "close Microsoft Office" in data:
msclose()
if "open text file" in data:
textfiles()
if "open text file" in data:
closetextfiles()
if "open WhatsApp" in data:
openexe()
if "close WhatsApp" in data:
closeexe()
if "open Visual Studio" in data:
editor()
if "close Visual Studio" in data:
closeedit()
if "open email" in data:
email()
if "open company website" in data:
google()
if "close service" in data:
sys.exit()
des()
except Exception as e:
print(e)
engine.say("please speak again")
return "None"
return query
#................................end jarvice functions....................................
def call():
while(1):
#engine.say("hello am a Jarvise Assistance")
#engine.say("The current Time is")
#times()
#engine.say('The Current date is')
#date()
#if hour >= 6 and hour<12:
#engine.say('good morning sir')
engine.say("commands is running sir")
#elif hour >= 12 and hour<18:
#engine.say('Good Afternoon sir')
#engine.say("commands is runnig sir")
#elif hour >= 18 and hour<24:
#engine.say('Good Evening sir')
#engine.say("commands is running sir ")
#else:
# engine.say('good night sir')
Commands()
engine.runAndWait()
#...........................
def hihello():
engine.say('hello sir')
engine.say('i am your assitant ')
# engine.say('a two it')
engine.say("How can i help you")
def editor():
my_programe="C:/Users/hmish/AppData/Local/Programs/Microsoft VS Code/Code.exe"
os.system('"%s"' % my_programe)
def closeedit():
#my_programe=filedialog.askopenfilename()
my_programe="C:/Users/hmish/AppData/Local/Programs/Microsoft VS Code/Code.exe"
#text_l.config(text=my_programe)
#x=os.system(my_programe)
os.system('"%s"' % +'TASKKILL /F /IM Code.exe')
#......................................open and close................
def openexe():
my_programe="C:/Users/hmish/Downloads/WhatsApp.exe"
os.system(my_programe)
def closeexe():
my_programe="C:/Users/hmish/Downloads/WhatsApp.exe"
os.system('TASKKILL /F /IM WhatsApp.exe')
new = 1
url = "https://mail.google.com"
def email():
webbrowser.open(url,new=new)
new2 = 1
url2 = "https://www.google.com/"
def google():
webbrowser.open(url2,new=new2)
def des():
root.destroy()
def textfiles():
my_programe="file.txt"
os.system(my_programe)
def closetextfiles():
my_programe="file.txt"
os.system('TASKKILL /F /IM file.txt')
def msoffice():
programe=("C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Microsoft Office/Microsoft Word 2010.lnk")
os.system('"%s"' % programe)
def msclose():
os.system('TASKKILL /F /IM Microsoft-Word-2010.lnk')
#......................................open close programe..............
#..................................jarvis function end...................
background_image=Label(root,image=bg_image,bd=0).place(x=0,y=0,relwidth=1,relheight=1)
btn_enter=Button(root,text="Enter",font=("times new roman",16),command=call,border="5",bg="black",activebackground='white',fg="white",activeforeground='black',cursor='hand2')
btn_enter.place(x=290,y=370,width=130,height=40)
#......................................... Clock .........................
def clock():
G_time=time.strftime("%H:%M:%S")
c_label.config(text=G_time)
c_label.after(1000,clock)
clock_frame=Frame(root,relief=RIDGE,bg="black")
clock_frame.place(x=280,y=15,width=140,height=40)
c_label=Label(clock_frame,bd=0,font=("arial",25,"italic"),fg="white",bg="black")
c_label.place(x=0,y=0)
clock()
#........................................ Clock End...................
w = Label(root, text=f"{dt.datetime.now():%a, %b %d %Y}", fg="white", bg="black", font=("helvetica", 25))
w.place(x=210,y=305,width=280,height=40)
#.......................center frame.................................
center_frame=Frame(root,relief=RIDGE,bg="white",bd=10)
center_frame.place(x=200,y=60,width=305,height=235)
fr_image=Label(center_frame,image=f_image,bd=0).place(x=0,y=0,relwidth=1,relheight=1)
ce_label=Label(center_frame,text=data,font=("arial",12,"italic"),fg="black",bg="white")
ce_label.place(x=10,y=10)
ce1_label=Label(center_frame,text="",font=("arial",12,"italic"),fg="black",bg="white")
ce1_label.place(x=30,y=30)
ce2_label=Label(center_frame,text="",font=("arial",12,"italic"),fg="black",bg="white")
ce2_label.place(x=50,y=50)
#.........................progress bar...................
my_progress =ttk.Progressbar(center_frame,orient=HORIZONTAL,mode="indeterminate")
my_progress.place(x=15,y=170,width=250)
def progress():
my_progress["value"]=40
my_progress.start(10)
progress()
#...........................second progress bar
root_progress =ttk.Progressbar(root,orient=VERTICAL,mode="indeterminate")
root_progress.place(x=100,y=70,width=25,height=200)
def progress1():
root_progress["value"]=40
root_progress.start(10)
progress1()
#...........................third progress bar................
root1_progress =ttk.Progressbar(root,orient=VERTICAL,mode="indeterminate")
root1_progress.place(x=570,y=70,width=25,height=200)
def progress2():
root1_progress["value"]=40
root1_progress.start(10)
progress2()
root.mainloop()