A simple Python tool to automatically generate subtitle (.srt) files from video files using OpenAI Whisper.
This project transcribes the audio from a video file and converts it into a properly formatted .srt subtitle file with timestamps.
- Introduction
- Features
- Installation
- Usage
- Dependencies
- Configuration
- Examples
- Troubleshooting
- Contributors
- License
Auto-Subtitle-Generator uses OpenAI's Whisper speech recognition model to transcribe video audio into text and automatically generate subtitle files in .srt format.
It is designed to be simple, lightweight, and easy to use.
- 🎤 Automatic speech recognition from video files
- 🕒 Generates accurate timestamped
.srtsubtitles - 📦 Supports multiple Whisper model sizes (
tiny,base,small,medium,large) - 📝 Easy-to-modify Python script
- 🎬 Works with most video formats (requires FFmpeg)
git clone https://github.com/KDurgaPrasad116/Auto-Subtitle-Generator.git
cd Auto-Subtitle-GeneratorInstall Whisper directly:
pip install git+https://github.com/openai/whisper.gitOr install using requirements (if available):
pip install -r requirements.txtWhisper requires FFmpeg for audio extraction.
- Windows: Download from https://ffmpeg.org/download.html
- Mac:
brew install ffmpeg- Ubuntu:
sudo apt install ffmpeg- Open the Python script.
- Set your video file path:
video_file = "sample_video.mp4"
subtitle_file = "output_subtitles.srt"
model_size = "base"- Run the script:
python main.py- The generated subtitles will be saved as:
output_subtitles.srt
You can modify:
| Variable | Description |
|---|---|
video_file |
Path to input video |
subtitle_file |
Output subtitle filename |
model_size |
Whisper model size |
tiny(Fastest, least accurate)basesmallmediumlarge(Most accurate, slower)
1
00:00:01,200 --> 00:00:03,500
Hello and welcome.
2
00:00:04,000 --> 00:00:06,800
This is an example subtitle.
sample_video.mp4– Sample input videooutput_subtitles.srt– Generated subtitle file
Upgrade pip first:
pip install --upgrade pipMake sure FFmpeg is installed and added to your system PATH.
If using GPU acceleration, ensure:
- Correct CUDA version installed
- Compatible PyTorch version
- Project Author: KDurgaPrasad116
Contributions are welcome! Feel free to fork and submit pull requests.
This project currently does not include a license file.
- Add CLI argument support
- Add support for
.vttformat - Add batch video processing
- Embed subtitles directly into videos
- Build a simple GUI interface
⭐ If you found this project useful, consider giving it a star!