AI-powered subtitle generation from video/audio using Whisper.
Project description
Subtitle Generator
Generate subtitles for video/audio files using whisper.cpp.
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.
Homebrew's
whisper-cpp1.8.4 dropped the-viflag we use to ingest video directly, sosubtitle setup-whisperis the recommended way to get a compatible binary.
Usage
# VTT (default), output in current directory
subtitle video.mp4
# SRT
subtitle video.mp4 --format srt
# Generate SRT and embed it into the video
# Writes ./video.srt and ./video_subtitled.mp4
subtitle video.mp4 --merge --format srt
# Larger model
subtitle video.mp4 --model large
# 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 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 |
subtitle formats |
Show supported subtitle formats |
Options
| Flag | Description |
|---|---|
--model, -m |
tiny / base / small / medium / large (default: base) |
--format, -f |
vtt / srt / txt / json / lrc (default: vtt) |
--merge |
Embed 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 |
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)
Links
- Source: https://github.com/innovatorved/subtitle
- Issues: https://github.com/innovatorved/subtitle/issues
License
MIT
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
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.5.tar.gz.
File metadata
- Download URL: subtitle_generator-3.0.5.tar.gz
- Upload date:
- Size: 33.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8be0d2e4a54569f59f073129e3733d22fd263e36c78b451a020957c365a71c1a
|
|
| MD5 |
7b8afdbfc512bf086d5c019f0171cddd
|
|
| BLAKE2b-256 |
f71d326c03da3d6826498fe0dd0ce6fb9fbfe0ae44877d201fcca1938915dde1
|
File details
Details for the file subtitle_generator-3.0.5-py3-none-any.whl.
File metadata
- Download URL: subtitle_generator-3.0.5-py3-none-any.whl
- Upload date:
- Size: 36.4 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 |
6e55de77db8060731edf3a67a92aa3406dde3b0105133a8796646b133f671298
|
|
| MD5 |
ab9f513b6fe263627eac4ae701e5c7b8
|
|
| BLAKE2b-256 |
c9f8f35b0e8e82c4b17a84cca8681a690bf63468a679d8513921b2988a8eb77a
|