whisper-captions
Docs · Project page · Changelog
Turn whisper.cpp output into caption-ready segments with whole-word timestamps — and SRT/VTT files.
whisper.cpp's word-level data is made of BPE tokens, not words. Join them
naively and you get captions like M uld oon, was p or friend ., plus
control tokens such as [_BEG_] and [_TT_150] leaking into the text.
whisper-captions fixes that:
tokens: "[_BEG_]" " Mul" "do" "on," " friend" "."
words: "Muldoon," "friend."
- Parses every whisper.cpp output you are likely to have:
-oj,-ojf(full JSON with tokens) and plain stdout ([00:00:01.000 --> 00:00:03.500] …) - Reassembles BPE tokens into whole words with start/end times
- Drops whisper's special tokens
- Normalizes whitespace and timestamps (strings, seconds or milliseconds)
- Exports SRT and WebVTT
- No whisper dependency — works on files from any whisper.cpp version, and
the token merger also accepts tokens from
whisper-rs
Usage
[]
= "0.1"
// whisper-cli -m ggml-base.en.bin -f audio.wav -ojf -of out
let json = read_to_string?;
let segments = parse_whisper_json_str?;
for segment in &segments
write?;
# Ok::
Only have stdout? parse_whisper_stdout(&text). Have both and want the best
available? parse_transcript(json.as_ref(), Some(&stdout)) prefers JSON and
falls back to stdout.
With whisper-rs
Collect the tokens of a segment as RawTokens and let the crate merge them:
use ;
let tokens = vec!;
let words = merge_bpe_tokens;
assert_eq!;
CLI example
Output
Segment and Word implement serde::Serialize/Deserialize and serialize
in camelCase, ready to hand to a frontend:
Origin
Extracted from Flixlar, a local caption editor, where it turns whisper.cpp auto-captions into editable subtitle tracks.
Author
Built and maintained by Mads Paaskesen, Hardcore Websmith at MP-IT. Need speech-to-text, a captioning pipeline or Whisper / FFmpeg / Rust tooling in your product? I take on freelance work: get in touch.
License
MIT