Create a Real Time Voice Translator using Python
In this tutorial, we’re going to develop a real time voice translator using Python.
Required Modules:
Following are the libraries or modules we will need for creating the real time translator:
- playsound: This module plays sounds in Python
- Googletrans: The “Googletrans” module can be used for free and is an unlimited Python library that implements the Google Translate API
- Speech Recognition Module: It is a library which can be used by Python for recognizing the commands provided. The pip is the preferred method to perform Speech Recognition.
- PyAudio: This module is used for taking the command from the user
- gTTs: The gTTs API supports various languages, such as English, Hindi, Tamil, French, German, and many more.
Basic Idea:
A real-time translator that can translate human language voice inputs and generates the output voice translation in the required language. It is built using Google’s googleTrans API and the speech_recognition library in Python. The program will convert the texts from one language into another language and save them as an audio file in mp3 format. The playsound module will used to play the created mp3 format file. Following that, the created MP3 file is removed by using the OS module.
Step By Step Implementation
Step 1: Import all the required Modules
Step 2: Creating a tuple of all the languages mapped with their code
Step 3: Taking the voice commands from the user end.
Step 4: Taking the voice input from the user end.
Step 5: Implementing the input destination language from the user end, and Map user input with the language code.
Step 6: Now we will invoke the Translator.
Step 7: Now, we will translate from src to dest
Step 8: Now, Save the Translated files and delete them after playing.
Full Implementation of Code:
Output: