A real-time speech recognition and translation tool using OpenAI's Whisper model.
This application captures audio from your microphone, transcribes it using OpenAI's Whisper speech recognition model, and translates the text to your desired language using Google Translate. It works in chunks of 5 seconds, providing near real-time interpretation.
- Real-time speech recognition using OpenAI's Whisper model
- Translation between numerous languages using Google Translate
- Configurable source and target languages
- Multiple Whisper model sizes to balance accuracy and performance
- Python 3.7+
- PyTorch
- OpenAI Whisper
- PyAudio
- googletrans
# Install dependencies
pip install torch whisper pyaudio googletrans==4.0.0-rc1 wave
Run the interpreter with default settings (English to Spanish):
python simultaneous-interpreter.py
Customize languages and model size:
python simultaneous-interpreter.py --source en --target fr --whisper medium
--source
,-s
: Source language code (default: en)--target
,-t
: Target language code (default: es)--whisper
,-w
: Whisper model size (choices: tiny, base, small, medium, large, default: base)
- The application initializes the Whisper model and Google Translator
- It records audio in 5-second chunks
- Each chunk is transcribed using Whisper
- The transcribed text is translated to the target language
- Both original and translated text are displayed in the console
- Press Ctrl+C to stop the interpreter
The application supports all languages available in both Whisper and Google Translate, including English, Spanish, French, German, Chinese, and many more.
The application uses ISO 639-1 language codes for translation. Some language codes include country codes (e.g., zh-CN or zh-TW).
Supported languages include:
- af: Afrikaans
- ar: Arabic
- bg: Bulgarian
- bn: Bengali
- ca: Catalan
- cs: Czech
- da: Danish
- de: German
- el: Greek
- en: English
- es: Spanish
- et: Estonian
- fa: Persian
- fi: Finnish
- fr: French
- he: Hebrew
- hi: Hindi
- hr: Croatian
- hu: Hungarian
- id: Indonesian
- it: Italian
- ja: Japanese
- ko: Korean
- lt: Lithuanian
- lv: Latvian
- ms: Malay
- nl: Dutch
- no: Norwegian
- pl: Polish
- pt: Portuguese
- ro: Romanian
- ru: Russian
- sk: Slovak
- sl: Slovenian
- sv: Swedish
- th: Thai
- tr: Turkish
- uk: Ukrainian
- ur: Urdu
- vi: Vietnamese
- zh-cn: Chinese (Simplified)
- zh-tw: Chinese (Traditional)
And many more supported by the googletrans library.