-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjarvis.py
More file actions
196 lines (119 loc) · 4.08 KB
/
jarvis.py
File metadata and controls
196 lines (119 loc) · 4.08 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
from speach import speak # for speaking use speak("enter text to speak")
from wish_me import wishMe # for wishing use wishMe()
from security import security # for login into the jarvis
import query_listener # the commands said by person (constant)
from screenshot import screenshot
import wikipedia
import webbrowser
import os
import datetime
import pyautogui
speak(" please login into your account")
print(" default username and password root ")
security()
speak("login succesfull")
print("login succesfull,,,,")
wishMe()
# functions for operational settings
def add():
a= query
lst=[]
for i in a.split():
if i.isdigit():
lst+=[int(i)]
d=sum(lst)
print(d)
def sub():
a= query
lst=[]
for i in a.split():
if i.isdigit():
lst+=[int(i)]
if len(lst)==2:
print(lst[1]-lst[0])
else:
print("subtraction requires only two operands")
def mul():
s=1
a= query
lst=[]
for i in a.split():
if i.isdigit():
lst+=[int(i)]
for i in lst:
s*=i
print(s)
def div():
a= query
lst=[]
for i in a.split():
if i.isdigit():
lst+=[int(i)]
if len(lst)==2:
if lst[1]!=0:
print(lst[0]/lst[1])
else:
print("divide by zero!")
else:
print("division requires only two operands")
#main program starts here
while True:
query_listener.takecommand()
query = query_listener.query
query = query.lower()
if "how are you" in query:
speak("fine sir,")
elif "division" in query or "divide" in query:
div()
elif "multiply" in query:
mul()
elif "add" in query:
speak("ok sir")
add()
elif "subtract" in query or "subtraction" in query or "substract" in query:
sub()
elif "screenshot" in query:
speak("taking screenshot")
speak("please enter path")
screenshot()
speak("screenshot has been saved")
elif 'wikipedia' in query:
speak('Searching Wikipedia....')
query =query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("according to wikipedia")
print(results)
speak(results)
elif 'open youtube' in query:
speak("opening youtube")
#webbrowser.open("youtube.com")
url = 'youtube.com'
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chrome_path).open(url)
elif 'open google' in query:
speak("opening google")
#webbrowser.open("google.com")
url = 'google.com'
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chrome_path).open(url)
elif 'open stackoverflow' in query or 'open stack overflow' in query:
webbrowser.open("stackoverflow.com")
# elif 'open file' in query:
# speak("enter file")
# path = pyautogui.prompt("Enter path of file")
# file = os.listdir(path)
# print(file)
# os.startfile(os.path.join(file))
elif 'search for' in query:
url = query
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chrome_path).open(url)
elif 'time' in query:
strTime = datetime.datetime.now().strftime('%H:%M:%S')
speak(f"sir, the time is {strTime}")
print(f"sir, the time is {strTime}")
elif 'stop' in query:
break
else:
print("say that again")
query=""