-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (37 loc) · 1.2 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
#starts the bot using pyttsx5 library takes care of speaking and reconising speech
#from source using speech_recognition library
import pyttsx3
import speech_recognition as sr
import datetime
import npl
engine = pyttsx3.init('sapi5') #sapi5
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
"""function that wishes as you start the program"""
hour=int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("hey!good morning....so how can i help you start your day?")
elif hour>12 and hour<18:
speak("hey!good afternoon...how was your day going on?")
else :
speak("hey!good evening...wanna listen some pleasent music?")
def takeCommand(): #docstring
r=sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
try:
query=r.recognize_google(audio,language='en-in')
except Exception as e:
speak("Say that again please..")
return "none"
return query
def now():
strTime=datetime.datetime.now().strftime("%H:%M:%S")
return strTime
if __name__ =="__main__":
wishMe()
npl.resp()