AI-powered subtitle generation from video/audio using Whisper.
Project description
Subtitle Generator
AI-powered subtitle generation using Whisper for accurate speech-to-text transcription.
Features
- 🎯 Multi-format output - VTT, SRT, TXT, JSON, LRC, ASS, TTML
- 🚀 Fast processing - Powered by whisper.cpp for high-performance inference
- 📦 Batch processing - Process multiple videos at once
- 🔄 Video embedding - Embed subtitles directly into videos
- 🌍 Multilingual - Support for multiple languages
Installation
pip install subtitle-generator
Prerequisites
- FFmpeg is required for video/audio processing:
# macOS brew install ffmpeg # Ubuntu/Debian sudo apt install ffmpeg # Windows (via chocolatey) choco install ffmpeg
Quick Start
# Generate subtitles (VTT format)
subtitle video.mp4
# Generate SRT format
subtitle video.mp4 --format srt
# Embed subtitles into video
subtitle video.mp4 --merge
# Use a larger model for better accuracy
subtitle video.mp4 --model large
CLI Commands
| Command | Description |
|---|---|
subtitle <video> |
Generate subtitles for a video |
subtitle models --list |
List available Whisper models |
subtitle models --download <model> |
Download a specific model |
subtitle batch --input-dir <dir> |
Batch process multiple videos |
subtitle formats |
Show supported output formats |
Options
| Option | Description |
|---|---|
--model, -m |
Model to use: tiny, base, small, medium, large |
--format, -f |
Output format: vtt, srt, txt, json, lrc, ass, ttml |
--merge |
Embed subtitles into the video file |
--threads, -t |
Number of processing threads |
--verbose, -v |
Enable verbose output |
Python API
from subtitle_generator.core import SubtitleGenerator, WhisperCppTranscriber
from subtitle_generator.models import ModelManager
transcriber = WhisperCppTranscriber(binary_path="./binary/whisper-cli")
generator = SubtitleGenerator(transcriber=transcriber, model_manager=ModelManager())
result = generator.generate(
input_path="video.mp4",
model_name="base",
output_format="srt",
output_dir="data",
)
print(f"Subtitles saved to: {result.output_path}")
Models
| Model | Size | Speed | Accuracy |
|---|---|---|---|
tiny |
~75MB | ⚡⚡⚡⚡ | ⭐⭐ |
base |
~140MB | ⚡⚡⚡ | ⭐⭐⭐ |
small |
~460MB | ⚡⚡ | ⭐⭐⭐⭐ |
medium |
~1.5GB | ⚡ | ⭐⭐⭐⭐⭐ |
large |
~3GB | 🐢 | ⭐⭐⭐⭐⭐ |
Tip: Use
.enmodels (e.g.,base.en) for English-only content for faster processing.
Links
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
subtitle_generator-3.0.0.tar.gz
(35.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subtitle_generator-3.0.0.tar.gz.
File metadata
- Download URL: subtitle_generator-3.0.0.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adc2639c03cccb18f881ffee5b3516a1b13d200efe8c4abc3de51ba8392943ee
|
|
| MD5 |
cac70792f846ee3ec1d4d74423a0f0eb
|
|
| BLAKE2b-256 |
0b5083c601c085f140f7e331552b61e52601e17a8c0101683c7aa09356e4ccd7
|
File details
Details for the file subtitle_generator-3.0.0-py3-none-any.whl.
File metadata
- Download URL: subtitle_generator-3.0.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d0ec5fa994138307fa876656e9ec4f2335b51835ef6d58a7e23fd760d77cdd0
|
|
| MD5 |
3c37054a8708093e2becfaa7c2a0b6f9
|
|
| BLAKE2b-256 |
5886c0508b0680046bcb82bdf08f2f3cc788b177274af658c95a7d1ad00b933f
|