CLI tool to transcribe and translate subtitles from videos
Project description
Transub
Turn any video into ready-to-share subtitles. Transub extracts audio with ffmpeg, runs Whisper to transcribe the speech track, and hands the text to an LLM so you get well-translated subtitles without leaving the terminal.
Table of Contents
- Overview
- Key Features
- Installation
- Configuration Overview
- CLI Cheatsheet
- Development
- Project Layout
- License
Overview
Transub orchestrates a reproducible pipeline:
- Extract audio from a video with
ffmpeg. - Transcribe speech via Whisper (local, mlx, whisper.cpp, or API).
- Translate subtitle batches with JSON-constrained prompts.
- Emit
.srtor.vttfiles with tuned line breaks and timing.
Intermediate state is cached so interrupted runs can resume without repeating earlier steps.
Key Features
- End-to-end pipeline —
transub run <video.mp4>handles extraction → transcription → translation → export. - Multiple transcription backends — choose local Whisper,
mlx-whisper,whisper.cpp, or OpenAI-compatible APIs. - Reliable translations — JSON-constrained prompts, retry logic, and configurable batch sizes.
- Subtitle polishing — punctuation-aware line splitting, timing offsets, and optional spacing tweaks when different scripts appear in the same line.
- Stateful execution — cached progress in the work directory (defaults to
~/.cache/transub) avoids rework across runs.
Installation
1. Prerequisites
- Python 3.10+
- ffmpeg: Must be installed and available in your system's
PATH.- Windows:
winget install Gyan.FFmpegorchoco install ffmpeg - macOS:
brew install ffmpeg - Linux:
sudo apt update && sudo apt install ffmpeg(Debian/Ubuntu) orsudo pacman -S ffmpeg(Arch)
- Windows:
2. Install Transub
Using uv (Recommended)
uv is a fast Python package installer and resolver. It installs CLI tools in isolated environments.
uv tool install transub
To update later, run:
uv tool upgrade transub
3. Install a Whisper Backend (Optional)
transub supports multiple Whisper backends. Choose one based on your needs:
-
Cloud API (Recommended for quick start):
- Uses OpenAI's Whisper API or compatible endpoints
- No local installation required
- Set
OPENAI_API_KEYenvironment variable - Configure with
backend = "api"during setup
-
Local backends (for offline use or custom models):
-
For most users (local, CPU/GPU):
pip install openai-whisper
-
For Apple Silicon (macOS):
pip install mlx-whisper
-
For
whisper.cpp: Follow the whisper.cpp installation instructions to build themainexecutable and make it available on yourPATH.
-
4. Configure Transub
Run the interactive setup wizard to create your configuration file.
transub init
The wizard will guide you through selecting the backend, model, and LLM provider for translation.
Note on API Keys: If you use OpenAI for both transcription (Whisper API) and translation (GPT models), they share the same OPENAI_API_KEY by default. If you need separate keys for different services, you can customize api_key_env in the config file for each service.
5. Run the Pipeline
transub run /path/to/your/video.mp4
Subtitles are written alongside the source video unless you set pipeline.output_dir in your config. Override the cache location with --work-dir when you need an alternate workspace.
Configuration Overview
Runtime settings live in transub.conf (TOML). Key sections:
[whisper]— backend selection, model name, device overrides, and extra arguments.[llm]— translation provider/model, temperature, batch size, retry policy.[pipeline]— output format, line-length targets, timing trim/offset, punctuation and spacing options.
Example:
[pipeline]
output_format = "srt"
translation_max_chars_per_line = 26
translation_min_chars_per_line = 16
normalize_cjk_spacing = true
timing_offset_seconds = 0.05
Run transub configure for an interactive editor, or update the file manually. Configuration files are user-specific and should not be committed.
CLI Cheatsheet
transub run demo.mp4 --config ~/transub.conf --work-dir /tmp/transub # override work dir (defaults to ~/.cache/transub)
transub show_config
transub init --config ./transub.conf # rerun the setup wizard
transub configure # edit config (0 saves, Q discards)
transub run demo.mp4 --transcribe-only # export raw transcription only
transub run demo.mp4 -T # short flag for transcribe-only
transub --version # print the installed version
The work directory (defaults to ~/.cache/transub) stores audio, transcription segments, translation progress, and pipeline state. If a run is interrupted, re-running the same command resumes where it left off. Use --work-dir to point at a custom cache location when needed.
Development
If you want to contribute to transub, you can set up a development environment.
Installation from Source
- Clone the repository:
git clone https://github.com/PiktCai/transub.git cd transub
- Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate
- Install in editable mode with development dependencies:
pip install -e ".[dev]"
- Install a Whisper backend for testing:
pip install openai-whisper
Running Tests
python -m unittest
Code Structure
- Source lives in
transub/(cli.py,config.py,transcribe.py,translate.py,subtitles.py, etc.). - Add tests beside related modules (e.g.,
transub/test_subtitles.py). - Use Rich console utilities and
transub.logger.setup_loggingfor consistent output.
Project Layout
transub/
├── audio.py
├── cli.py
├── config.py
├── subtitles.py
├── transcribe.py
├── translate.py
└── test_subtitles.py
License
This project is distributed for personal use and study; there is no formal contribution process at this time.
Transub is released under the MIT License.
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
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 transub-0.2.2.tar.gz.
File metadata
- Download URL: transub-0.2.2.tar.gz
- Upload date:
- Size: 55.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b116ae8ae649da6deec332c88da5de59e4e5088417a02e2a31e1b6463107e0e0
|
|
| MD5 |
5bf9886a0078cbe31242d0a7f7ec8930
|
|
| BLAKE2b-256 |
14206614f36e7b801cdca28623cebe8c2925ec3ff702f4ba4dee31f2fd134154
|
Provenance
The following attestation bundles were made for transub-0.2.2.tar.gz:
Publisher:
publish.yml on PiktCai/transub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transub-0.2.2.tar.gz -
Subject digest:
b116ae8ae649da6deec332c88da5de59e4e5088417a02e2a31e1b6463107e0e0 - Sigstore transparency entry: 707546123
- Sigstore integration time:
-
Permalink:
PiktCai/transub@633d7f8303601fdb70ca070a71bd047370a906fb -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/PiktCai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@633d7f8303601fdb70ca070a71bd047370a906fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file transub-0.2.2-py3-none-any.whl.
File metadata
- Download URL: transub-0.2.2-py3-none-any.whl
- Upload date:
- Size: 54.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c6dd568ca298f1dd7c4886507cd5a23769609530a8e0cdb3df06eb34eb48542
|
|
| MD5 |
f2f9dc50d89968cab03b9eae3ffb1e3a
|
|
| BLAKE2b-256 |
80615e7df14ffd31b0ca5f185e4abdabb4975db4bdcccdf43132833b5a42fc20
|
Provenance
The following attestation bundles were made for transub-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on PiktCai/transub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transub-0.2.2-py3-none-any.whl -
Subject digest:
2c6dd568ca298f1dd7c4886507cd5a23769609530a8e0cdb3df06eb34eb48542 - Sigstore transparency entry: 707546127
- Sigstore integration time:
-
Permalink:
PiktCai/transub@633d7f8303601fdb70ca070a71bd047370a906fb -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/PiktCai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@633d7f8303601fdb70ca070a71bd047370a906fb -
Trigger Event:
release
-
Statement type: