-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (48 loc) · 1.58 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
import smtplib
import speech_recognition as sr
import pyttsx3 as speak
from email.message import EmailMessage
from color import colors
listener = sr.Recognizer()
engine = speak.init()
def talk(text):
print(text)
engine.say(text)
engine.runAndWait()
def get_info():
try:
with sr.Microphone() as source:
print(f"{colors.fg.yellow}listening....{colors.reset}")
voice = listener.listen(source)
info = listener.recognize_google(voice)
print(info)
return info.lower()
except:
pass
def send_mail(receiver, subject, msg_body):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('[email protected]', 'Director_1975')
email = EmailMessage()
email["From"] = "[email protected]"
email["To"] = receiver
email["Subject"] = subject
email.set_content(msg_body)
server.send_message(email)
email_list = {
# This object is like the email diectory, i.e., EmailBot will use the shortnames to refer to email addresses.
"ayush": "[email protected]",
}
def get_email_info():
talk("To whom you want to send the email")
name = get_info()
receiver = email_list[name]
talk("What is the subject of your email?")
subject = get_info()
talk("What is the message?")
msg_body = get_info()
prGreen("Your mail has been sent successfuly!")
print(f"{colors.fg.green}Success:Your mail has been sent successfully!!{colors.reset}")
talk("Sent Sir!")
send_mail(receiver, subject, msg_body)
get_email_info()