Skip to content

BrunoSantos751/TranslatedSubGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

TranslatedSubGen

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 .srt subtitle file and optionally burns subtitles into the video

⚙️ Requirements

  • Python 3.8+
  • FFmpeg installed and in PATH (required by moviepy)
  • ImageMagick installed with magick.exe accessible (for rendering text on video)

📦 Installation

  1. Clone the repository or download the files:
git clone https://github.com/BrunoSantos751/TranslatedSubGen.git
cd TranslatedSubGen
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file with your configuration:
DEEPL_AUTH_KEY=your_deepl_api_key_here
SOURCE_LANG=KO
TARGET_LANG=PT-BR

🛠️ .env Configuration

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)

▶️ How to use

Place your video file named as "target_video.mp4" in the same folder as the script and run:

python translate.py

This will:

  1. Extract audio from the video
  2. Generate transcription using Whisper
  3. Translate the transcript using DeepL API
  4. Create a synchronized .srt subtitle file

📁 File Structure

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

🧠 Main Features

  • ✅ 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 .env to keep API keys and languages configurable and secure

📝 Notes

  • Ensure ImageMagick is installed and properly configured.
    • On Windows, update the magick.exe path in the script (moviepy.config.IMAGEMAGICK_BINARY).
  • Whisper transcription time depends on model size and video length. Use smaller models for faster processing.

🧪 Tested With

  • Python 3.10
  • Whisper v1.1
  • DeepL API Free Plan
  • FFmpeg 6.0
  • MoviePy 1.0.3
  • ImageMagick 7.1

💡 License

This project is for personal use. Feel free to adapt it as needed.


About

TranslatedSubGen is a tool that extracts audio from a video, transcribes it using OpenAI’s Whisper, and translates the subtitles into your chosen language via DeepL. It outputs a ready-to-use .srt file with accurate and natural subtitles for multilingual content.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages