-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjarvis.py
198 lines (145 loc) · 5.71 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
import pyttsx3
import speech_recognition as sr
import datetime
import webbrowser
import pywhatkit
import os
import wikipedia
import pyautogui
import time
import cv2
Assistant = pyttsx3.init('sapi5')
voices = Assistant.getProperty('voices')
print(voices)
Assistant.setProperty('voices', voices[0].id)
Assistant.setProperty('rate', 170)
def Speak(audio):
print(" ")
Assistant.say(audio)
print(f"{audio}")
print(" ")
Assistant.runAndWait()
def takecommand():
command = sr.Recognizer()
with sr.Microphone() as source:
print("nexus is listening....")
command.pause_threshold = 1
audio = command.listen(source)
try:
print("nexus is searching....")
query = command.recognize_google(audio, language='en-US')
print(f"user said: {query}")
except Exception as Error:
return "none"
return query.lower()
def TaskExe():
def Music():
Speak("tell me the name of the song sir")
musicName = takecommand()
if 'once upon a time' in musicName:
os.startfile('C:\\Users\\User\\OneDrive\\Desktop\\songs\\Once-Upon-a-Time.mp3')
elif 'Lokiverse' in musicName:
os.startfile('C:\\Users\\User\\OneDrive\\Desktop\\songs\\Lokiverse.mp3')
else:
pywhatkit.playonyt(musicName)
Speak("done sir! enjoy your song sir")
def Whatsapp():
Speak("tell me the name of the contact you want to send message to sir")
name = takecommand()
if 'amma' in name:
Speak("Tell me the message sir")
msg = takecommand()
Speak("Tell me the time sir")
Speak("time in hour")
hour = int(takecommand())
Speak("time in minutes")
mino = int(takecommand())
pywhatkit.sendwhatmsg("+96891464921", msg, hour, mino, 20)
Speak("ok sir sending the whatsapp message to amma")
elif 'daddy' in name:
Speak("Tell me the message sir")
msg = takecommand()
Speak("Tell me the time sir")
Speak("time in hour")
hour = int(takecommand())
Speak("time in minutes")
mino = int(takecommand())
pywhatkit.sendwhatmsg("+96895116479", msg, hour, mino, 20)
Speak("ok sir sending the whatsapp message to daddy")
else:
Speak("Tell me the phone number")
Phone = int(takecommand())
ph = '+968' + Phone
Speak("Tell me the message sir")
msg = takecommand()
Speak("Tell me the time sir")
Speak("time in hour")
hour = int(takecommand())
Speak("time in minutes")
mino = int(takecommand())
pywhatkit.sendwhatmsg(ph, msg, hour, mino, 20)
Speak("ok sir sending the whatsapp message to amma")
Speak("your command has been successfully completed")
while True:
query = takecommand()
tt = time.strftime("%I:%M %p")
if "hello" in query:
Speak(f"hi sir its {tt} how may i help you?")
elif "how are you" in query:
Speak("im good sir thank you for asking how may i help you")
elif "you need a break" in query:
Speak("ok sir call me when you need me and have a great day...")
break
elif 'thank you' in query:
Speak("no problem i am always there for you")
elif "bye" in query:
Speak("ok sir bye see you later")
break
elif "i am good" in query:
Speak("thats nice sir how may i help you")
elif "youtube search" in query:
Speak("ok sir this is what i found for your search sir")
query = query.replace("nexus","")
query = query.replace("youtube search","")
web = 'https://www.youtube.com/results?search_query=' + query
webbrowser.open(web)
Speak("Done sir")
elif "google search" in query:
Speak("This is what i found for your search sir")
query = query.replace("nexus", "")
query = query.replace("google search", "")
pywhatkit.search(query)
Speak("Done sir")
elif "website" in query:
Speak("ok sir launching website")
query = query.replace("nexus", "")
query = query.replace("website", "")
web1 = query.replace("open", "")
web2 = "https://www." + web1 + ".com"
webbrowser.open(web2)
Speak("launched sir")
elif "launch" in query:
Speak("tell me the name of the website sir")
name = takecommand()
web = "https://www." + name + ".com"
webbrowser.open(web)
Speak("done sir")
elif 'music' in query:
Music()
elif 'wikipedia' in query:
Speak("Searching wikipedia...")
query = query.replace("nexus", "")
query = query.replace("wikipedia", "")
wiki = wikipedia.summary(query, 2)
Speak(f"According to wikipedia : {wiki}")
elif 'whatsapp message' in query:
Whatsapp()
elif "screenshot" in query:
Speak("sir please hold on im taking the screenshot")
time.sleep(4)
img = pyautogui.screenshot()
Speak("sir what name should i save this picture to")
name = takecommand()
img.save(f"{name}.jpeg")
Speak("done sir any other help")
TaskExe()