How to make a voice assistant for E-mail in Python?
As we know, emails are very important for communication as each professional communication can be done by emails and the best service for sending and receiving mails is as we all know GMAIL. Gmail is a free email service developed by Google. Users can access Gmail on the web and using third-party programs that synchronize email content through POP or IMAP protocols.
To connect Gmail with Voice Assistant we have to use Gmail API. In this article, we will see how to send and check emails by giving voice commands. The Gmail API lets you view and manage Gmail mailbox data like threads, messages, and labels. More information about Gmail API can be found here- Gmail API.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
- Python(3 or greater)
- A Gmail Account
- Google API Client
- pyttsx3 module
- speech_recognition module
Install the libraries by running the following commands:
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
Run this or pyttsx3:
pip install pyttsx3
Run this for speech recognition:
pip install SpeechRecognition
Now there is a need to set up a Google Cloud console to interact with the Gmail API. This can be done very easily. You can find information on how to set up a Google cloud console.
After setting up the Google Cloud console, we just need to make an approach for building a voice assistant to speak up emails.
- Import required modules.
- Create the below functions:
- speak( ): This function will help our assistant to speak up.
- get_audio( ): This function will help the assistant to get the input by the user.
- check_mails( ): This function is used to check unread emails in the primary section of the inbox.
- Call the above-created function.
Below is the implementation in Python.