This project provides a simple Python application for real-time speech transcription and translation. It leverages the speech_recognition library for speech-to-text conversion and Google Translate for text translation into a target language.
-
Real-time speech recognition using a microphone.
-
Transcription of spoken words into text in the source language.
-
Translation of transcribed text into a target language.
-
Support for multiple source and target languages.
Ensure you have the following installed:
-
Python 3.7+
-
Libraries
-
speech_recognition
-
googletrans==4.0.0-rc1
-
Clone the repository or download the script.
-
Install the required Python libraries using pip: pip install speechrecognition googletrans==4.0.0-rc1
-
Ensure your microphone is connected and accessible.
-
Run the script:
python speech.py
-
Follow the prompts:
-
Enter the source language (e.g., English, Spanish, French, etc.).
-
Speak into your microphone to have your speech transcribed and translated in real-time.
- Press Ctrl+C to stop the application.
Welcome to Real-Time Speech Translation!
Enter the source language (e.g., English, Spanish, French, German, etc.): English
Listening...
Recognized speech: Hello, how are you?
Translated text: Hola, ¿cómo estás?
The application supports the following languages:
-
English
-
Spanish
-
French
-
German
-
Italian
-
Chinese
-
Hindi
-
Japanese
-
Korean
-
Portuguese
-
Russian
-
Bengali
-
Marathi
-
Gujarati
-
Kannada
get_language_code(language_name)
-
Maps common language names to their respective language codes.
-
Returns the language code for use in speech recognition and translation APIs.
transcribe_and_translate_realtime(source_language, target_language)
-
Uses the speech_recognition library to capture speech from a microphone.
-
Transcribes the speech into text using Google Web Speech API.
-
Translates the transcribed text to the target language using Google Translate.
-
Continuously listens for speech until interrupted.
-
Unknown Speech: If the Google Web Speech API cannot understand the input, the application will notify the user.
-
API Errors: If there's an issue with the speech recognition API, an error message will be displayed.
-
Add support for custom target languages specified by the user.
-
Improve error handling for network or API issues.
-
Allow dynamic adjustment of microphone sensitivity.