Generate SRT subtitles from audio/video files using WhisperX
Project description
subtitle-engine
Generate .srt subtitle files from audio or video files using WhisperX. Optionally generate a caption from the transcript with a local Ollama LLM.
Installation
Requires Python 3.12 or newer.
pip install subtitle-engine
Or install from source:
git clone https://github.com/leevipuntanen/subtitle-engine.git
cd subtitle-engine
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Usage
# Basic usage — writes <input>.srt next to the source file
subeng video.mp4
# Specify output file
subeng video.mp4 --output subtitles.srt
# Use a different model or language
subeng video.mp4 --model medium --language fi
# Force CPU / CUDA
subeng video.mp4 --device cpu
# Speaker diarization (requires a Hugging Face token)
subeng video.mp4 --diarize --hf-token $HF_TOKEN
# Generate a caption from the transcript using Ollama
subeng video.mp4 --caption --ollama-model qwen3.5:0.6b
# Short-form subtitles (2-5 words per line, default)
subeng video.mp4 --preset shortform
# Long-form subtitles (10-14 words per line)
subeng video.mp4 --preset longform
Options
| Option | Description |
|---|---|
--output, -o |
Output SRT file path |
--model, -m |
WhisperX model: tiny, base, small (default), medium, large-v2, large-v3 |
--language, -l |
ISO language code, e.g. en, fi. Auto-detected if omitted. |
--device, -d |
cpu or cuda. Auto-detected if omitted. |
--batch-size, -b |
Inference batch size (default: 16) |
--compute-type, -c |
int8 or float16. Auto-selected if omitted. |
--diarize |
Enable speaker diarization |
--hf-token |
Hugging Face token for diarization (or set HF_TOKEN env var) |
--caption |
Generate a caption from the transcript via Ollama |
--ollama-model |
Ollama model name (required with --caption) |
--ollama-host |
Ollama API host (default: http://localhost:11434) |
--preset, -p |
Subtitle style: shortform (2-5 words, default) or longform (10-14 words) |
Development
Run the test suite:
pytest
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
subtitle_engine-0.1.3.1.tar.gz
(17.9 kB
view details)
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_engine-0.1.3.1.tar.gz.
File metadata
- Download URL: subtitle_engine-0.1.3.1.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d04b125ad5d2d082421dcea550b7e0225e5bfa3c2f9036014dca85cf5fc6573
|
|
| MD5 |
87f6f6b9de142548feaf1a7d3eefd755
|
|
| BLAKE2b-256 |
205e528e0473ae0898d33b60c40c83a9cc988180b4de95891a7fa2d6ab56a998
|
File details
Details for the file subtitle_engine-0.1.3.1-py3-none-any.whl.
File metadata
- Download URL: subtitle_engine-0.1.3.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6702f36da826b46711f84609556b4fcaa92c8c14eb1fdab5bddec2e22ddc71e8
|
|
| MD5 |
c1940c6cd5414bdeaa4fbe2f62f1f887
|
|
| BLAKE2b-256 |
aa2f55986f75565bdbbc1c12c135d7bd286320bc3a364efd682887d8ae2cbb91
|