Skip to main content

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.8b

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)

Development

Run the test suite:

pytest

License

MIT

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

subtitle_engine-0.1.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

subtitle_engine-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file subtitle_engine-0.1.1.tar.gz.

File metadata

  • Download URL: subtitle_engine-0.1.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for subtitle_engine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 beb3c17b5c4787a5bcb3dff9f91d88e497ec33522f4f35680214cec99b0e3149
MD5 5f90dc9f7d054922e92e105289072ca5
BLAKE2b-256 a1542f0fcf47fabaeb73aee43af9c27800d9f8ce18950e59bd264b302a8fe0bf

See more details on using hashes here.

File details

Details for the file subtitle_engine-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for subtitle_engine-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc1e1ca7deebc1aa38d44c4a62a03a2dddfb198f95aa0f84e97acd0e80ecef02
MD5 6d4f148e86aa9ba6a591f4899c5403c3
BLAKE2b-256 8bd4532ca1bc67f1d083ff694b31d016569b7c8e02cc9da86fd3a4f7d9422806

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