Vioce Assistant by Python
Vioce Assistant by Python
ASSISTANT
HARRY
BY
K MANOJ KUMAR (18STUCHH010419)
SWAROOCHISHRAO (18STUCHH010412)
t
TABLE OF CONTENTS
1.0 INTRODUCTION
1.1 What is voice assistant?
1.2 What can this A.I. assistant do for you?
2.0 DEFINING FUNCTIONS
2.1 DEFINING SPEAK FUNCTION
2.1.1 What is pyttsx3?
2.1.2 What is sapi5?
2.1.3 What is voiceid?
2.2 DEFINING WISH ME FUNCTION
2.3 DEFINING TAKE COMMANDS FUNCTION
3.0 CREATING OUR MAIN FUNCTION
4.0 TASKS PERFORMED VA
4.1 TO SEARCH SOMETHING ON WIKIPEDIA
4.2 TO OPEN YOUTUBE IN WEBBROWSER
4.3 TO OPEN GOGGLE IN WEBBROWSER
4.4 TO PLAY MUSIC
4.5 TO SENT GMAILS
4.6 TO KNOW THE CURRENT TIME
5.0 CONCLUSION
6.0 CODE
6.1
INTRODUCTION
WHAT IS VOICE ASSISTANT
A Virtual assistant is a technology based on artificial
intelligence. the software uses a devices microphone to
receive voice requests while the voice output takes place
at the speaker
It’s the combination of several different technologies:
voice recognition, voice analysis and language processing
It is completely developed using python language.
What Is VoiceId?
Voice id helps us to select different voices.
voice[0].id = Male voice
voice[1].id = Female voice
except Exception as e:
# print(e)
print("Say that again please...") #Say that again will be
printed in case of improper voice
return "None" #None string will be returned
return query
Creating Our main() function:
We will create a main() function, and inside this main()
Function, we will call our speak function.
if __name__=="__main__" :
speak("Whatever you will write inside this speak() function
will be converted into speech.")
CONCLUSION Recapitulate
First of all, we have created a wishme() function
that gives the greeting functionality according to
our A.I system time.
After wishme() function, we have created
a takeCommand() function, which helps our A.I to
take command from the user. This function is also
responsible for returning the user's query in a
string format.
We developed the code logic for opening different
websites like google, youtube, and stack overflow
CODE
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices[1].id)
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning!")
else:
speak("Good Evening!")
def takeCommand():
#It takes microphone input from the user and
returns string output
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio,
language='en-in')
print(f"User said: {query}\n")
except Exception as e:
# print(e)
print("Say that again please...")
return "None"
return query
if __name__ == "__main__":
wishMe()
while True:
# if 1:
query = takeCommand().lower()