-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
154 lines (117 loc) · 4.41 KB
/
main.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
import os
import speech_recognition as sr
import win32com.client
import webbrowser
import datetime
import pywhatkit
speaker = win32com.client.Dispatch("SAPI.SpVoice")
import smtplib
from email.message import EmailMessage
# Functions
# Taking Voice Command Function
def takecommand():
r = sr.Recognizer()
with sr.Microphone() as source:
r.pause_threshold=0.5
audio = r.listen(source)
try:
query = r.recognize_google(audio, language="en-in")
print(f" User said {query}")
return query
except Exception as e:
speaker.Speak("Sorry didn't heard you")
print("Sorry didn't heard you ")
# Sending Email Functions
def send_email(subject,message,receiver):
email_address = '###################' # Enter your Email Id
password = '' # Enter your Password
msg = EmailMessage()
msg.set_content(message)
msg['Subject'] = subject
msg['From'] = email_address
msg['To'] = receiver
with smtplib.SMTP('smtp.gmail.com', 587) as smtp:
smtp.starttls()
smtp.login(email_address, password)
smtp.send_message(msg)
speaker.Speak("Hello I am Jarvis")
print("Hello I am AI BOT")
# List
Email={
"me":"###############"
}
contacts = {
"Me": "+91#########"
}
sites = {
"Youtube": "www.youtube.com", "Google": "www.google.com", "Wikipedia": "www.wikipedia.com"
}
apps = {
"Notepad": "notepad.exe",
"Teams": "C:\\Users\\vyoms\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe",
"Python": "C:\\Program Files\\JetBrains\\PyCharm 2023.1.3\\bin\\pycharm64.exe",
"Java":"C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.3.2\\bin\\idea64.exe",
"vs code": "C:\\Users\\vyoms\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe",
"excel":"C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE",
"powerpoint":"C:\\Program Files\\Microsoft Office\\root\\Office16\\POWERPNT.EXE",
"word":"C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.EXE",
# Enter application name with its path
}
folder={
"download":"C:\\Users\\users\\Downloads",
# Enter folder name with its path
}
while 1:
print("Listening....")
text = takecommand()
if text is None:
speaker.Speak("Waiting For your Command")
continue
speaker.Speak(text)
# Open for Opening website, Application and Folder
if "Open".lower() in text.lower():
if "website" in text.lower():
for site in sites:
if f"Open website {site}".lower() in text.lower():
speaker.Speak(f"Opening {site}")
webbrowser.open(sites[site])
elif "folder" in text.lower():
for fold in folder:
if f"Open {fold}".lower() in text.lower():
speaker.Speak(f"Opening {fold} Folder")
os.startfile(folder[fold])
else:
for app in apps:
if f"Open {app}".lower() in text.lower():
speaker.Speak(f"Opening {app}")
os.startfile(apps[app])
# To play music on youtube
if "Play Music".lower() in text.lower():
text=text.replace("play music"," ")
pywhatkit.playonyt(text)
# To tell time
if "the time".lower() in text.lower():
datetime1=datetime.datetime.now().strftime("%H:%M:%S")
speaker.Speak(f"Time is {datetime1}")
# to send whatsapp message
if "send whatsapp message " in text.lower():
speaker.Speak("Sending Message")
text.replace("send whatsapp message"," ")
for contact in contacts:
if contact.lower() in text.lower():
speaker.Speak("What's the message is ")
message=takecommand()
pywhatkit.sendwhatmsg_instantly(contacts[contact], message, 15)
speaker.Speak(f"Message Send to {contact}")
# to send email
if "send email" in text.lower():
speaker.Speak("Sending Email")
text.replace("send email"," ")
for mail in Email:
if mail.lower() in text.lower():
speaker.Speak("What the subject is??")
subject=takecommand()
speaker.Speak("What the mail is??")
content=takecommand()
receiver=Email[mail]
send_email(subject,content,receiver)