Word-By-Word Captions (wbw-captions)
A Python tool to generate synchronized one-word captions for videos using word-level timestamps from WhisperX.
Overview
WBW takes WhisperX's word-level timestamp JSON output and creates visually appealing videos with synchronized one-word captions.
The JSON file generated by WhisperX with the high-precision word-level timestamps is required as input.
Installation
pip install word-by-word-captions
Dependencies
- ffmpeg (for video processing)
Usage
1. Generate Word-level Timestamps
First, use WhisperX to generate word-level timestamps for your audio/video:
# Install WhisperX
pip install git+https://github.com/m-bain/whisperX.git
# Generate word-level timestamps
whisperx <audio.wav> --hf_token <your-token> --vad_method silero --language <lang> --model <model> --align_model <align_model>
This will create a JSON file with precise word timings.
2. Create Captioned Video
# Add captions to an existing video
wbw-captions -v input_video.mp4 -j whisperx_output.json -o output.mp4
Options:
-v, --video: Input video file (optional)-j, --json: WhisperX JSON output file (required)-o, --output: Output video file path (required)--max_lines: Maximum number of lines per subtitle (default: 1)--max_line_chars: Maximum characters per line (default: 40)
Example Output
The tool creates videos where:
- Each word is highlighted in yellow as it's spoken
- Words are synchronized with precise timing from WhisperX
- Text is easily readable with proper contrast and outlines
- Captions are positioned at the bottom with proper margins
Development
To set up the development environment:
- Clone the repository
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
License
MIT License
Release files for word-by-word-captions 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| word_by_word_captions-1.0.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| word_by_word_captions-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.3 kB
Release files / word_by_word_captions-1.0.0.tar.gz
| Download URL | word_by_word_captions-1.0.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fccc0c3027d963e2e0654588be32f5b8ac0b02449396cfc3f2aa7a834cf151dd
|
|
BLAKE2b-256 checksum How to use checksums |
2458ea3f2cf57a654406dcb643bdfc5729e843700ff9a5141f3c2e99311b5af1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / word_by_word_captions-1.0.0-py3-none-any.whl
| Download URL | word_by_word_captions-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c69a9b7627042d0128126611e2e2f0fba4c7bb75545cd7cfd40ecdd1c819e1d4
|
|
BLAKE2b-256 checksum How to use checksums |
27b2f83fc0bdb1fe2c7017879ba78b6eb6e3918f6febbd9836ff2fd04b5850c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|