Skip to main content

Local subtitle generation and translation CLI using Whisper and NLLB-200

Project description

subtool

Local AI-powered subtitle generation and translation

PyPI Version Python Versions License UV Friendly CI Publish

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 - English
  • es - Spanish
  • fr - French
  • de - German
  • it - Italian
  • pt - Portuguese
  • ru - Russian
  • ja - Japanese
  • ko - Korean
  • zh - Chinese
  • ar - Arabic
  • hi - Hindi

More languages available in NLLB-200 documentation.

Whisper Models

Available models (trade-off between speed and accuracy):

  • tiny - Fastest, least accurate
  • base - Fast, decent accuracy
  • small - Balanced
  • medium - Good accuracy, slower
  • large - Best accuracy, slowest
  • turbo - 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 ffmpeg installed 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtool-0.0.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subtool-0.0.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for subtool-0.0.3.tar.gz
Algorithm Hash digest
SHA256 50ed1445cf385040a3b1b0fa467e020a6b5c86670c762b2c25c23e0050603c9a
MD5 21aa99730b6318f121f9784d238d243f
BLAKE2b-256 857da009e642f98b6449d76a24693aa47b70db918395e7fa76cc29d0ca590bfa

See more details on using hashes here.

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

Hashes for subtool-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 12254eee22f137bf6fe4189b15a9e05f8f8f6eaf52e7cbde83f4ab888f9c37ed
MD5 a8ecd6a21692cfc592e00088f7ea4566
BLAKE2b-256 b1330917529b160719b985a4b882d7fdedcee250fd2287c181678bb0c6fddc70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page