-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_01.txt
227 lines (152 loc) · 5.36 KB
/
backup_01.txt
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
import speech_recognition as sr
import pyttsx3
import webbrowser
import datetime
from datetime import date
import pywhatkit
import os
import smtplib
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
listener = sr.Recognizer()
listener_2 = sr.Recognizer()
engine = pyttsx3.init()
voices= engine.getProperty("voices")
engine.setProperty("voice",voices[1].id)
rate= engine.getProperty("rate")
engine.setProperty("rate", 150)
path="C:\\Program Files\\chromedriver.exe"
def speak(audio):
engine.say(audio)
engine.runAndWait()
engine.stop()
def get_command():
with sr.Microphone() as source:
print("listening...")
listener.pause_threshold = 1
voice= listener.listen(source, phrase_time_limit=5)
#listener.dynamic_energy_threshold = False
try:
print("recognizing...")
command= listener.recognize_google(voice, language='en-IN')
print(command)
except Exception:
print("I didn't catch it")
return "None"
return command
def date():
today= date.today()
date= today.strftime("%B %d, %Y")
print(date)
speak(date)
def play_onyt():
song= command.replace("play","")
speak("playing" +song)
pywhatkit.playonyt(song)
def music_offline():
music_source= "D:\\MC\\The Official UK Top 40 Singles Chart (06.11.2020) Mp3 (320kbps) [Hunter]\\The Official UK Top 40 Singles Chart (06.11.2020)"
songs= os.listdir(music_source)
print(songs)
os.startfile(os.path.join(music_source, songs[0]))
def send_email(reciever,msg):
x= reciever.replace(" ","")
y= x.lower()
print(f"Reciever's Email: {y}@gmail.com")
message=f'Subject: {"Email from Tharinda" }\n\n {msg}'
print(f"Message: {msg}")
server =smtplib.SMTP("smtp.gmail.com",587)
server.starttls()
server.login('tharindahp@gmail.com', 'seethepositiveside')
print("login ok")
server.sendmail('tharindahp@gmail.com', y+'@gmail.com' , message)
print("sent!!!")
def download_song(songName):
driver_1= webdriver.Chrome(path)
driver_1.get("https://musicpleer24.com/")
search= driver_1.find_element_by_id("searchField")
search.send_keys(songName)
search.send_keys(Keys.RETURN)
time.sleep(3)
speak("Now you can choose the exact one and click on it")
def go_to_wikipedia():
driver_2= webdriver.Chrome(path)
driver_2.get("https://www.wikipedia.org/")
time.sleep(2)
speak("What do you want to search?")
print("listening...")
try:
with sr.Microphone() as source:
voice= listener.listen(source, phrase_time_limit=10)
print("recognizing...")
thing= listener_2.recognize_google(voice, language="en-IN")
driver_2.maximize_window()
search= driver_2.find_element_by_id("searchInput")
search.send_keys(thing)
search.send_keys(Keys.RETURN)
speak("Here is what I found")
except Exception:
pass
def go_to_google(command):
try:
driver_3= webdriver.Chrome(path)
driver_3.get("https://www.google.com/")
search= driver_3.find_element_by_name("q")
search.send_keys(command)
time.sleep(1)
search.send_keys(Keys.RETURN)
driver_3.maximize_window()
time.sleep(1)
speak("Here is what i found on google")
except Exception:
print("N")
#while True:
command= get_command().lower()
if "open bing" in command:
webbrowser.open("bing.com")
speak("Opening Bing")
elif "open youtube" in command:
webbrowser.open("youtube.com")
speak("Opening Youtube")
elif "play music offline" in command:
music_offline()
elif "the date" in command:
date()
elif "who is" or "what is" or "where is" or "how many" or "tell me" in command:
go_to_google(command)
elif "wikipedia" in command:
go_to_wikipedia()
elif "download the song" or "download song" in command:
songName= command.replace("download the song", "")
download_song(songName)
elif "send an email" or "send a mail" or "send mail" in command:
speak("Who do you want to send?")
with sr.Microphone() as source:
print("listening...")
voice= listener.listen(source, phrase_time_limit=5)
try:
reciever= listener.recognize_google(voice, language='en-IN')
print(reciever)
except Exception:
speak("sorry, I couldn't hear Say again")
driver.implicitly_wait(4)
speak("Tell me your message")
with sr.Microphone() as source:
print("listening...")
voice= listener.listen(source, phrase_time_limit=8)
print("recognizing...")
try:
msg= listener.recognize_google(voice, language='en-IN')
except Exception:
speak("sorry, I couldn't hear.Say again.")
send_email(reciever,msg)
speak("Your email was sent")
elif "what's your name" or "your name" in command:
speak("I'm alpha")
command= get_command().lower()
elif "who are you" in command:
speak("I'm your personal assistance at the moment")
elif "are you single" in command:
speak("Yes, I'm single")
else:
pass