-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
227 lines (201 loc) · 8.3 KB
/
Copy pathmain.py
File metadata and controls
227 lines (201 loc) · 8.3 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
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
import pywhatkit
import speech_recognition as sr
import pyttsx3
import requests
import smtplib
import datetime
import pyautogui
import wikipedia
import pyjokes
import langdetect
import winsound
import os
from bs4 import BeautifulSoup
from myid import password, my_gmail , destination
from time import sleep
p = password
g = my_gmail
d = destination
engine = pyttsx3.init("sapi5")
voices = engine.getProperty('voices')
engine.setProperty("voice", voices[0].id)
engine.setProperty('rate', 170)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def takecommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('listening...')
r.pause_threshold = 1
r.energy_threshold = 250
audio = r.listen(source, 0 ,5)
try:
print('understanding..')
query = r.recognize_google(audio , language= 'en-in')
print(f"you said: {query}\n")
except Exception as e:
print('say that again')
return "none"
return query
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(g,p)
server.sendmail(g , d , content)
server.close()
def alarm(query):
timehere = open("alarmText.txt","a")
timehere.write(query)
timehere.close()
os.starthere("alarm.py")
if __name__ == "__main__":
while True:
query = takecommand().lower()
if "wake up " in query:
from GreetMe import greetMe
greetMe()
while True:
query = takecommand().lower()
if "go to sleep" in query:
speak("ok,you can call me anytime")
break
elif "hello" in query:
speak("hello, how are you?")
elif "i am fine" in query:
speak("what would you like me to do?")
elif "how are you " in query:
speak("i am perfect in your care")
elif "thank you " in query:
speak("your welcome")
elif "set alarm" in query:
print("input time example: 10 and 10 and 10")
speak("set the time")
a = input("please tell the time: ")
alarm(a)
speak("alarm has been set")
elif ' send email ' in query:
try:
speak("What should I say?")
content = takecommand()
to = d
sendEmail(to, content)
speak("Email has been sent !")
except Exception as e:
print(e)
speak("I am not able to send this email")
elif "open" in query:
from oAPP import openWebApp
openWebApp(query)
elif "close" in query:
from oAPP import closeWebApp
closeWebApp(query)
elif "play bg music" in query:
speak("playing..")
winsound.PlaySound('file_example_WAV_2MG.wav',winsound.SND_ASYNC | winsound.SND_ALIAS)
sleep(5)
elif "stop bg music" in query:
winsound.PlaySound(None, winsound.SND_ASYNC)
elif "google " in query:
from search import searchGoogle
searchGoogle(query)
elif 'tell me about ' in query:
person = query.replace('tell me about', '')
info = wikipedia.summary(person, 3)
print(info)
speak(info)
elif 'date' in query:
speak('sorry ,i have a date with wifi')
elif 'are you single' in query:
speak('i have a girlfriend')
elif 'joke' in query:
print(pyjokes.get_joke())
speak(pyjokes.get_joke())
elif "youtube" in query:
from search import searchYT
searchYT(query)
elif "wikipedia" in query:
from search import searchWiki
searchWiki(query)
elif "translate" in query:
from GoogleTrans import LangTrans
LangTrans(query)
elif "pause" in query:
pyautogui.press("k")
speak("paused")
elif "video play" in query:
pyautogui.press("k")
speak("video play")
elif "mute" in query:
pyautogui.press("m")
speak("video mute")
elif "volume up" in query:
from keyboard import volumeup
speak("increasing volume")
volumeup()
elif "volume down" in query:
from keyboard import volumedown
speak("decreasing volume")
volumedown()
elif "read" in query:
from Audiobook import audioBook
audioBook(query)
elif "remember that" in query:
rememberMsg = query.replace("remember that","")
rememberMsg = query.replace("Ai","")
speak("you told me to remember that"+ rememberMsg )
remember = open("remember.txt", "a")
remember.write(rememberMsg)
remember.close()
elif "what do you remember" in query:
remember = open("remember.txt", "r")
speak("you told me to remember that"+ remember.read())
elif "news" in query:
from newsRead import latestnews
latestnews()
elif "automate whatsapp " in query:
name = query.replace("automate whatsapp ", "")
name = name.replace("send", "")
name = name.replace("to","")
Name = str(name)
speak(f"whats the message for{Name}")
msg = takecommand()
from automation import WhatsAppmsg
WhatsAppmsg(Name,msg)
elif "whatsapp" in query:
pywhatkit.sendwhatmsg("+916375154236","padhle ya soja",15,50)
elif "whatsapp group" in query:
pywhatkit.sendwhatmsg_to_group("group_name", "hey, how's is everyone!",15,30)
elif "shutdown the system" in query:
speak("Are You sure you want to shutdown")
shutdown = input("Do you wish to shutdown your computer? (yes/no)")
if shutdown == "yes":
os.system("shutdown /s /t 1")
elif shutdown == "no":
break
elif "temperature" in query:
search = "temperature in churu"
url = f"https://search.brave.com/search?q={search}"
R = requests.get(url)
data = BeautifulSoup(R.text,"html.parser")
temp = data.find("div", class_ = "BNeawe").text
speak(f"current{search} is {temp}")
elif "weather" in query:
search = "temperature in churu"
url = f"https://search.brave.com/search?q={search}"
R = requests.get(url)
data = BeautifulSoup(R.text,"html.parser")
temp = data.find("div", class_ = "BNeawe").text
speak(f"current{search} is {temp}")
elif "time" in query:
strTime = datetime.datetime.now().strftime("%H:%M")
speak(f"the current time is {strTime}")
elif "play music" in query:
speak('playing..')
music = "C:\\Users\\Anamika Computer\\Music"
song = os.startfile(os.path.join(music))
sleep(15)
elif "finally sleep" in query:
speak("bye sir, going to rest tata ")
exit()