-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathjarvis.py
111 lines (81 loc) · 3.28 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
import webbrowser
import pyttsx3
import speech_recognition as sr
import pywhatkit
import os
assistant = pyttsx3.init('sapi5')
voices = assistant.getProperty('voices')
assistant.setProperty('voices',voices[0].id)
assistant.setProperty('rate',170)
def speak(audio):
print(" ")
assistant.say(audio)
print(f": {audio} ")
assistant.runAndWait()
def takecommand():
command = sr.Recognizer()
with sr.Microphone() as source:
print('Listening ... ')
command.pause_threshold = 1
audio = command.listen(source)
try:
print("Recongnizing......")
query = command.recognize_google(audio,language='en-in')
print("You said: {query}")
except Exception as Error:
return "none"
return query.lower()
def taskxe():
def music():
speak("Tell me the name of your song ! ")
musicname = takecommand()
if 'seven rings' in musicname :
os.startfile('Music\\Ariana Grande - 7 rings.mp3')
else:
pywhatkit.playonyt(musicname)
speak(" Song , STarted , Enjoy sir")
while True:
query = takecommand()
if 'hello ' in query:
speak('Hello I am Jarvis')
speak('Your personal AI assistance , How may I help YOU ')
elif 'how are you' in query:
speak('I am fine ma\'am , how are you ')
elif 'i am good' in query:
speak('Glad to hear maam ' )
elif 'good morning jarvis ':
speak('very good morning maam ' )
break
elif 'youtube search' in query:
speak('Okay sir , This is what I found for your search! ')
query = query.replace("Jarvis" , "" )
query = query.replace("youtube search","")
web='https://www.youtube.com/results?search_query='+ query
webbrowser.open(web)
speak("done maam")
elif 'you need a break' in query:
speak('Okay maam you can call me any time , have a good day ')
break
elif 'bye jarvis':
speak('Bye maam ')
break
elif 'google search ' in query:
speak('this is what i found')
query = query.replace('jarvis',"")
query = query.replace('google search'," ")
pywhatkit.search(query)
speak('done, sir')
elif 'website' in query:
speak('okay sir launching .....')
query = query.replace('jarvis',"")
query = query.replace('website',"")
web1 = query.replace('open',"")
web2 = 'https://www.'+web1+'.com'
webbrowser.open(web2)
speak('Launched ! ')
elif "music" in query:
music()
# elif 'wikipedia' in query:
speak("jarvis , ACTIVATED ")
taskxe()
#on hold