Skip to main content

CLI for generating and translating subtitles with WhisperX

Project description

Subtatix

Subtatix is a small CLI for generating .srt (or .vtt) subtitles with local AI from audio or video files with optional translation. Everything is processed on your machine.

Generate subtitles from my-video.mp4 into my-video.srt and my-video.es.srt (Spanish):

subtatix transcribe my-video.mp4 --to es

It relies heavily on WhisperX for transcription and subtitle timing alignment.

Requirements

  • Python 3.12+
  • ffmpeg installed separately and available on your PATH
  • Enough disk space for model downloads and caching

The first run will be slower because WhisperX and translation models need to be downloaded. Subsequent runs reuse the cached models and do not need to download them again unless the cache is cleared.

ffmpeg is an external system dependency. It is not installed by pip, uvx, or uv tool install.

Installation

Run without installing:

uvx subtatix --help

Install as a tool with uv:

uv tool install subtatix

Install with pip:

pip install subtatix

or from my Forgejo PyPI instance:

uvx --index https://forgejo.chrispaganon.com/api/packages/chris-paganon/pypi/simple/ subtatix --help
uv tool install --index https://forgejo.chrispaganon.com/api/packages/chris-paganon/pypi/simple/ subtatix
pip install --index-url https://forgejo.chrispaganon.com/api/packages/chris-paganon/pypi/simple/ subtatix

Usage

transcribe creates subtitles from an audio or video file. It writes .srt by default:

subtatix transcribe input.mp4
subtatix transcribe input.mp4 --from en --to es --output translated/subtitles
subtatix transcribe input.mp4 --to es --discard-transcription

The first command writes input.srt. The second writes translated/subtitles.srt and translated/subtitles.es.srt. --discard-transcription writes only the translated output when used with --to.

translate translates an existing .srt or .vtt file without transcribing audio or video:

subtatix translate input.srt --from en --to es --output translated/subtitles
subtatix translate input.vtt --from en --to es

For translation-only mode, the input must be an .srt or .vtt file and --from is required. These commands write translated/subtitles.es.srt and input.es.vtt.

Common options and discovery commands:

subtatix transcribe input.mp4 --format vtt
subtatix translate input.srt --from en --to es --format vtt
subtatix transcribe input.mp4 --batch-size 4 --device cpu
subtatix list languages
subtatix list source-languages
subtatix list target-languages

Passing an --output value that ends in a subtitle suffix like .srt or .vtt is rejected. Use a base path such as --output subtitles instead.

Models

By default, transcription uses WhisperX with the Whisper model large-v2. This is a good general default when you want higher transcription quality and aligned subtitle timings, but it is heavier and slower than smaller Whisper models.

Translation uses facebook/nllb-200-1.3B. The CLI accepts simple target codes such as en, es, fr, de, pt, ja, ko, zh, and also raw NLLB codes such as spa_Latn.

Other model options can also be used:

  • For transcription, you can pass another Whisper model with --model, such as small, medium, or large-v3, depending on your speed and accuracy needs.
  • For translation, the code currently defaults to the NLLB model above, but the translation layer is built around Hugging Face seq2seq models and could be adapted to use a different multilingual translation model if needed.

Examples:

subtatix transcribe input.mp4 --model small
subtatix transcribe input.mp4 --model large-v3 --to spa_Latn
subtatix list target-languages

Limitations

  • Translations are processed one subtitle cue at a time to preserve the original timing exactly. The tradeoff is that each cue is translated without the surrounding subtitle lines, so some lines may sound less natural when they depend on nearby context.
  • Adding nearby cues as extra context is not reliable with regular translation models, because they cannot tell which text is only context and which text must actually be translated.
  • Translating larger blocks and splitting them back into subtitle cues is also not a good fit. Translation can reorder or merge sentence parts across cue boundaries, making it impossible to split the result back without damaging the timing.
  • A typical llm model could handle context more explicitly, but that would make translation much slower, heavier, and less predictable, especially with smaller local models.

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

subtatix-0.2.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

subtatix-0.2.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file subtatix-0.2.2.tar.gz.

File metadata

  • Download URL: subtatix-0.2.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for subtatix-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c5a9be325fccab1304442eab2c9c31cb0338418b1ea040d30b912cee32538322
MD5 0c8a95805fa232a976650b7ae9532343
BLAKE2b-256 fd7a5e219f31d958ed5c32751367d0be2b6d436781d90e7afdb8397b3a744b83

See more details on using hashes here.

File details

Details for the file subtatix-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: subtatix-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for subtatix-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b296fb20c4bfdce770662c2d3e85f0ed768fc3b33eafad1ae57a4db5fb8d91a
MD5 606c1d73fd0456d302025e78a22a3125
BLAKE2b-256 6586695f5b93206e39e82a57d58dc53e8597aa0d4b4efac886bd1965ef2c7434

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