forked from Veershah26/virtual-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
113 lines (97 loc) · 2.63 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
from modules.Apicommand import *
from modules.photo_with_python import *
from modules.ScreenShot import *
from modules.StressBusters import *
from modules.WallpaperScrapper import *
from modules.weather import *
from modules.wiki import *
from modules.YoutubeVideoDownloader import *
import pyttsx3
import datetime
import speech_recognition as sr
from modules.mp3 import *
from modules.send_mail import *
ttsengine = pyttsx3.init()
def speak(audio):
ttsengine.say(audio)
ttsengine.runAndWait()
def getvoices(voice):
voices = ttsengine.getProperty('voices')
# print(voices[1].id)
if voice == 1:
ttsengine.setProperty('voice', voices[0].id)
if voice == 2:
ttsengine.setProperty('voice', voices[1].id)
speak("Hello Darkness My Old Friend")
def time():
Time = datetime.datetime.now().strftime("%I:%M %p")
speak("The Current Time Is")
speak(Time)
# print(Time)
def date():
today = datetime.datetime.now()
today_date = today.strftime("%m/%d/%Y")
speak("The Current Date Is ")
speak(today_date)
# while True:
# voice = int(input("Enter 1 or 2: "))
# speak(audio)
# getvoices(voice)
# time()
def greeting():
hour = datetime.datetime.now().hour
if hour >= 6 and hour <12 :
speak("Good Morning Sir !")
elif hour >=12 and hour <18 :
speak("Good Afternoon Sir !")
else :
speak("Good Evening Sir !")
def wishme():
speak("Welcome Back Sir!")
greeting()
time()
date()
speak("How May I Help You")
# wishme()
def takecmd():
query = input("Please Tell Me How May I Help You ? \n")
return query
def takecmdmic():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognising...")
query = r.recognize_google(audio, language="en-IN")
print(query)
except Exception as e:
print(e)
speak("Pardon Me Sir. Can you say that again please..")
return "None"
return query
if __name__ == "__main__":
wishme()
api()
photo_with_python()
playmusic()
email_send()
StressBusters()
WallpaperScrapper()
#weather function which doesnt work because of non existent api key
# temp()
# detail()
# rain()
# pressure()
# wind()
# humidity()
# clouds()
wiki('Python')
downloadYtMp4('https://www.youtube.com/watch?v=lHhRhPV--G0') #random video to test functionality
while True:
query = takecmdmic().lower()
if 'time' in query:
time()
elif 'date' in query:
date()