Repository navigation
whisper: word-level timestamps using DTW - #254
Open
Ved-Padmawar wants to merge 1 commit into
Open
Ved-Padmawar wants to merge 1 commit into
Ved-Padmawar wants to merge 1 commit into
Conversation
Add TRANSCRIBE_TIMESTAMPS_WORD for Whisper variants with a known alignment-head preset. After each 30 s window, a forced decoder pass collects alignment-head cross-attention, which is normalized, median-filtered and aligned to audio frames with DTW, following OpenAI's timing.py and whisper.cpp. Closes handy-computer#240
Ved-Padmawar
force-pushed
the
feat/whisper-dtw
branch
from
November 11, 2026 01:06
a3fad53 to
19fcd53
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #240
This PR adds word-level timestamps to Whisper through
TRANSCRIBE_TIMESTAMPS_WORD.Whisper currently provides segment-level timestamps, which aren't precise enough for streaming use cases like LocalAgreement. When trimming committed audio, we need to know exactly where a word ends rather than relying on the timestamp of an entire segment.
To address this, I've added a DTW-based alignment approach similar to what's used in OpenAI's
timing.pyand whisper.cpp.After each 30-second window is decoded, an additional forced decoder pass extracts cross-attention from the alignment heads. The attention weights are then median-filtered and aligned with audio frames using DTW to estimate individual word boundaries.
The feature is opt-in and uses the existing timestamp enum and word accessors, so no public API or ABI changes are needed.
For now, word-level timestamps are supported on standard OpenAI Whisper models with known alignment-head presets. Other checkpoints will continue using segment-level timestamps.
Scope
alignment.{h,cpp}undersrc/arch/whisperfor DTW-based word alignment.AI Assistance
I used AI to help with parts of the implementation, tests, and documentation. I've reviewed the changes, tested the implementation, and take responsibility for the final code.
Validation
Tested word-level timestamps on the following models using CPU:
All new unit tests and smoke tests pass.
On whisper-base, Vulkan output matches CPU. CUDA and Metal haven't been tested yet.
The existing text decoding path remains unchanged, so this shouldn't affect transcription accuracy or WER.
Example output
Using
whisper-basewithsamples/jfk.wavand--timestamps word: