Skip to main content

Subtitle Generator

Generate subtitles for video/audio files using whisper.cpp.

PyPI License: MIT Python 3.9+

Install

pip install subtitle-generator
subtitle setup-whisper          # one-time: clones + builds whisper-cli

subtitle setup-whisper needs git, cmake, a C++ compiler, and ffmpeg:

# macOS
xcode-select --install && brew install cmake ffmpeg
# Linux
sudo apt-get install -y build-essential cmake git ffmpeg
# Windows
# Install Git, CMake, VS Build Tools, ffmpeg.

The built binary lands in your per-OS user data dir (e.g. ~/Library/Application Support/subtitle-generator/bin/ on macOS) and is auto-discovered on every subsequent run.

subtitle setup-whisper builds innovatorved/whisper.cpp (develop), which includes -vi for direct video ingestion. If a stock whisper-cli without -vi is used instead, subtitle-generator automatically extracts 16 kHz mono WAV via ffmpeg.

Usage

# VTT (default), output in current directory
subtitle video.mp4

# SRT
subtitle video.mp4 --format srt

# Generate SRT and embed soft subtitles into the video
# Writes ./video.srt and ./video_subtitled.mp4
subtitle video.mp4 --merge --format srt

# Burn (hardcode) subtitles into the video
# Writes ./video.srt and ./video_burned.mp4
subtitle video.mp4 --burn --format srt

# Fast high-accuracy model (large-v3-turbo) or full large-v3
subtitle video.mp4 --model turbo
subtitle video.mp4 --model large

# Specify language or translate to English
subtitle video.mp4 --language es --translate

# Short-form / TikTok / Reels captions (word-boundary splitting)
subtitle video.mp4 --format srt --max-len 16 --split-on-word

# Initial prompt for vocabulary / proper nouns
subtitle video.mp4 --prompt "Whisper.cpp, PyPI, FFmpeg"

# Convert between subtitle formats (vtt, srt, csv, lrc, txt)
subtitle convert video.vtt video.srt

# Custom output directory
subtitle /path/to/video.mp4 --output-dir ~/subs --format srt

Subcommands

Command Description
subtitle <video> Transcribe and write subtitle file
subtitle <video> --merge Transcribe + mux soft subtitles into a copy of the video
subtitle <video> --burn Transcribe + burn hard subtitles into a copy of the video
subtitle setup-whisper Build whisper-cli into user data dir (one-time)
subtitle models --list List/check downloaded models
subtitle batch --input-dir <dir> Batch-process a directory in parallel
subtitle convert <in> [out] Convert existing subtitle files (vtt, srt, csv, lrc, txt)
subtitle formats Show supported subtitle formats

Options

Flag Description
--model, -m tiny / base / small / medium / turbo / large-v3 / large (default: base)
--format, -f vtt / srt / txt / json / lrc / csv (default: vtt)
--language, -l Spoken language code (en, es, auto, etc.)
--translate, -tr Translate speech to English
--max-len, -ml Maximum segment length in characters (e.g. 16 for short-form captions)
--split-on-word, -sow Split segments on word boundaries rather than tokens
--prompt Initial prompt to guide vocabulary, names, or formatting
--merge Embed soft subtitles into a copy of the video
--burn Burn hard subtitles into a copy of the video
--output-dir, -o Output directory (default: current dir)
--threads, -t whisper.cpp thread count
--whisper-binary Override the auto-discovered whisper-cli path
--models-dir Override the model cache directory
--verbose, -v Verbose output
--version, -V Show version

Python API

from subtitle_generator.core import SubtitleGenerator, WhisperCppTranscriber
from subtitle_generator.models import ModelManager

generator = SubtitleGenerator(
    transcriber=WhisperCppTranscriber(),
    model_manager=ModelManager(),
)
result = generator.generate(
    input_path="video.mp4",
    model_name="base",
    output_format="srt",
)
print(result.output_path if result.success else result.error)

License

MIT

Metadata

Release files for subtitle-generator 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for subtitle-generator 3.2.0
File Size Uploaded Provenance
subtitle_generator-3.2.0.tar.gz 40.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for subtitle-generator 3.2.0
File Interpreter ABI Platform
subtitle_generator-3.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 82.5 kB

Release files / subtitle_generator-3.2.0.tar.gz

Download URL subtitle_generator-3.2.0.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c5f0c77a82b147b7e16b1997bb1090e979a2cdc3f30c517dcd4bc46638462da1
BLAKE2b-256 checksum
How to use checksums
5a385d3cdd3db89f20b84e8950af512de4b0dad5dcea85ce02610332eed3dd42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / subtitle_generator-3.2.0-py3-none-any.whl

Download URL subtitle_generator-3.2.0-py3-none-any.whl
Size 41.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7cdb0cdd3b57ec87405e43710dadc5f579b8d4ac181bf5a18766da0f9004ac8
BLAKE2b-256 checksum
How to use checksums
5a9528e2c7b63bd74f2eb6d1db17907ba57ecfd0adc8d14dfc20faa5f4722247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for subtitle-generator 3.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page