A Python tool that automatically generates subtitles for videos using OpenAI's Whisper model, with optional translation support. The tool transcribes audio from videos and can create subtitle files in both the original language and a translated version.
- Automatic speech recognition using OpenAI's Whisper model
- Support for multiple languages
- Automatic translation capabilities
- Configurable settings via YAML file
- Generated SRT subtitle files with proper formatting
- Easy-to-use command line interface
- Clone this repository:
git clone https://github.com/AhmedOsamaMath/video-subtitle-generator.git
cd video-subtitle-generator
- Install the required packages:
pip install -r requirements.txt
Create a config.yaml
file in the project directory with your desired settings:
# Whisper model to use (tiny, base, small, medium, large)
whisper_model: "base"
# Source language of the video
source_language: "en"
# Whether to generate translated subtitles
translate: true
# Target language for translation
target_language: "ar"
Basic usage with default configuration:
python script.py path/to/your/video.mp4
The script generates two SRT files:
videoname_en.srt
- Original language subtitlesvideoname_ar.srt
- Translated subtitles (if translation is enabled)
Replace en
and ar
with your actual source and target language codes.
video-subtitle-generator/
βββ script.py # Main script
βββ config.yaml # Configuration file
βββ requirements.txt # Project dependencies
βββ README.md # Documentation
This project is licensed under the MIT License - see the LICENSE file for details.