TranslatedSubGen is a tool that:
- Extracts audio from a video
- Automatically transcribes using Whisper
- Translates to another language using the DeepL API
- Generates a synchronized
.srtsubtitle file and optionally burns subtitles into the video
- Python 3.8+
- FFmpeg installed and in PATH (required by
moviepy) - ImageMagick installed with
magick.exeaccessible (for rendering text on video)
- Clone the repository or download the files:
git clone https://github.com/BrunoSantos751/TranslatedSubGen.git
cd TranslatedSubGen- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your configuration:
DEEPL_AUTH_KEY=your_deepl_api_key_here
SOURCE_LANG=KO
TARGET_LANG=PT-BR| Variable | Purpose |
|---|---|
DEEPL_AUTH_KEY |
Your API key for DeepL |
SOURCE_LANG |
Language code of the video audio (e.g., JA, EN, KO) |
TARGET_LANG |
Desired subtitle language (e.g., PT-BR, EN, FR) |
Place your video file named as "target_video.mp4" in the same folder as the script and run:
python translate.pyThis will:
- Extract audio from the video
- Generate transcription using Whisper
- Translate the transcript using DeepL API
- Create a synchronized
.srtsubtitle file
| File | Purpose |
|---|---|
translate.py |
Main script |
requirements.txt |
List of dependencies |
.env |
Sensitive and configuration variables |
target_video.mp4 |
Input video (rename as needed) |
target_video_subtittle.srt |
Generated translated subtitle file |
- ✅ Uses Whisper (OpenAI) for automatic speech transcription
- ✅ Uses DeepL API for high-quality translations
- ✅ Subtitle optimization:
- Merges short adjacent segments
- Sets minimum and maximum subtitle durations
- Limits line and subtitle character length
- ✅ Uses
.envto keep API keys and languages configurable and secure
- Ensure ImageMagick is installed and properly configured.
- On Windows, update the
magick.exepath in the script (moviepy.config.IMAGEMAGICK_BINARY).
- On Windows, update the
- Whisper transcription time depends on model size and video length. Use smaller models for faster processing.
- Python 3.10
- Whisper v1.1
- DeepL API Free Plan
- FFmpeg 6.0
- MoviePy 1.0.3
- ImageMagick 7.1
This project is for personal use. Feel free to adapt it as needed.