Local subtitle generation and translation CLI using Whisper and NLLB-200
Project description
subtool
Local AI-powered subtitle generation and translation
Extract and translate video subtitles using Whisper and NLLB-200.
Features
- Automatic speech recognition using OpenAI Whisper (auto-detects language)
- Multi-language translation using Meta's NLLB-200 model
- Subtitle embedding into video files (MP4 or MKV)
- Multiple subtitle tracks with proper language naming
- SRT and ASS format support (ASS for better Unicode/CJK character rendering)
Install
Recommended (fast, reproducible):
uv tool install subtool
Run without installing:
uvx subtool video.mp4 -t en es
With pip:
pip install subtool
Usage
# Basic usage - extract subtitles (auto-detect language)
subtool video.mp4
# Extract and translate to English and Spanish
subtool video.mp4 -t en es
# Specify source language explicitly
subtool video.mp4 -l zh -t en
# Use different Whisper model (default: turbo)
subtool video.mp4 -m large -t en
# Output as MKV (better subtitle support for Unicode/CJK)
subtool video.mp4 -t en zh -f mkv
# Generate SRT files only (no embedding)
subtool video.mp4 -t en es --srt-only
# Custom output path
subtool video.mp4 -t en -o output_with_subs.mp4
Supported Languages
Translation supports 12 common languages:
en- Englishes- Spanishfr- Frenchde- Germanit- Italianpt- Portugueseru- Russianja- Japaneseko- Koreanzh- Chinesear- Arabichi- Hindi
More languages available in NLLB-200 documentation.
Whisper Models
Available models (trade-off between speed and accuracy):
tiny- Fastest, least accuratebase- Fast, decent accuracysmall- Balancedmedium- Good accuracy, slowerlarge- Best accuracy, slowestturbo- Fast and accurate (default)
Output Formats
- MP4 (default): Compatible but limited Unicode support for subtitles
- MKV: Better subtitle support, recommended for Chinese/Japanese/Korean content
MKV uses ASS format with embedded font information for proper CJK character rendering.
Development
uv sync
uv run subtool video.mp4 -t en # run the CLI using local code
# optional: editable install
uv pip install -e .
./scripts/release.sh # release a new version
Notes
- First run downloads Whisper model (~1.5GB for turbo) and NLLB-200 model (~1.2GB)
- Models are cached in
~/.cache/huggingface/ - Requires
ffmpeginstalled on your system - Generated subtitle files (.srt and .ass) are saved alongside the video
- For best CJK (Chinese/Japanese/Korean) subtitle rendering, use MKV format (
-f mkv)
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 subtool-0.0.3.tar.gz.
File metadata
- Download URL: subtool-0.0.3.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50ed1445cf385040a3b1b0fa467e020a6b5c86670c762b2c25c23e0050603c9a
|
|
| MD5 |
21aa99730b6318f121f9784d238d243f
|
|
| BLAKE2b-256 |
857da009e642f98b6449d76a24693aa47b70db918395e7fa76cc29d0ca590bfa
|
File details
Details for the file subtool-0.0.3-py3-none-any.whl.
File metadata
- Download URL: subtool-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12254eee22f137bf6fe4189b15a9e05f8f8f6eaf52e7cbde83f4ab888f9c37ed
|
|
| MD5 |
a8ecd6a21692cfc592e00088f7ea4566
|
|
| BLAKE2b-256 |
b1330917529b160719b985a4b882d7fdedcee250fd2287c181678bb0c6fddc70
|