By Mehul Gupta
This tutorial consists of designing an Alexa-like personal voice assistant using Python that can interpret voice commands using speech recognition on your own desktop and can perform many tasks.
As python contains pre-defined libraries and modules that help in performing tasks easily within our desktop and browser, that is why we choose python for this project.
First, we have to install these libraries before importing them to IDE using:
pip install SpeechRecognition
(and other modules using this command)
SpeechRecognition: It is a Python speech recognition library that is used to convert our voice into text.
Pyttsx3: It is a text-to-speech conversion library in Python. Unlike other alternative libraries, it works offline and is compatible with both Python 2 and 3.
Wikipedia: It is a Python library that makes it easy to access and parse data from Wikipedia. We can access any information about any personality, monuments, place using this library from our voice assistant.
Here, Microsoft speech API is used that SAPI5 that contains inbuilt voice for the system which can be used for our assistant.
To start with, we need to import the Webbrowser module, which enables the assistant to execute your query in any internet browser.For the tasks below, I have selected the Chrome browser. In this project, we will perform certain tasks like the following
4.Importing WolframAlpha module and API for Mathematical Calculation:
For this task, you have to upload your unique API-ID that will be available after you make an account on Wolframapha.com, and from their user setting, you can download the id. After applying this function, any mathematical queries that you speak to your assistant can be solved using this web API integration. You can proceed with your query by saying 'Calculate':
5. Importing Pywhatkit, Datetime, and Subprocess libraries:
This library may be used to search the browser or play a certain video on YouTube using your voice in the takeCommand function, and it can automatically open YouTube based on your query. It can also be used to send WhatsApp messages by using the library's built-in methods.
The DateTime library is used to obtain precise time information from the assistant through your query. The subprocess library is used to start programs in your operating system; you can write a note using your voice, and it will be stored in Notepad in real-time.
Conclusion: This is a good project for understanding the hands-on python programming language approach, play with this project by adding more commands, libraries, and modules. Once, you get familiarise with this project then you can extend this program according to your need like It gives a basic understanding of how a simple program-based assistant can be turned into a live chat-bot after applying your skills and other technologies.
Submitted by Mehul Gupta (mehul15)
Download packets of source code on Coders Packet