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.1.tar.gz
(35.7 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.1.tar.gz.
File metadata
- Download URL: subtitle_generator-3.0.1.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d8e9837a48c7baff5d8798055442863d096af52ea1bfa9558b9b12bfad6c685
|
|
| MD5 |
2a5206fe95114778362262b2e2380dba
|
|
| BLAKE2b-256 |
bd651f678d6137accf5f923d9f3316981316d3050d24bcc8816b3854688f102d
|
File details
Details for the file subtitle_generator-3.0.1-py3-none-any.whl.
File metadata
- Download URL: subtitle_generator-3.0.1-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.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4e2f72562f5394bfdf92deaad3decea2eab72e378dcdd94fe4ddebf0c720296
|
|
| MD5 |
baa599fc87e4b27c3fdb8fdebd39a92e
|
|
| BLAKE2b-256 |
b5d48fcc78c9d78c71b7a563f2d81494f507f11f55cd0e10bbcc05cd1b478659
|