Add word-level timestamps to batched decoding - #14
Merged
Merged
Conversation
add_word_timestamps was only called when batch_size=1, so word_timestamps=True had no effect with batching (the default for LightningWhisperMLX): segments had no words and the SRT/VTT word options did nothing. Each window in a batch is now aligned against its own mel segment, using that window's seek for the time offset. hallucination_silence_threshold relies on moving seek window by window, which a batch cannot do; it now warns when combined with batch_size > 1 instead of being dropped silently. Tests run a random-weight model so the alignment pass is real. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TMXYMqgLAykqRApmbRfpTA
1 of 3 tasks
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.
What does this PR do?
Closes #4.
add_word_timestampswas only called whenbatch_size=1, soword_timestamps=Truedid nothing with batching, which is the default forLightningWhisperMLX. Segments had nowords, and the SRT/VTT word options did nothing. Each window in a batch is now aligned against its own spectrogram, using that window'sseek(fixed in Keep text after the last timestamp pair in batched decoding #13) for the time offset.hallucination_silence_thresholdneeds window-by-window seeking, which a batch can't do. Withbatch_size > 1it now warns instead of being dropped silently, and the docstring says so.random_whisper()builds a small random-weight model, so the alignment pass in tests is real (cross-attention + DTW).How was this tested?
pytest): 24 passedvayu audio.mp3)tests/test_word_timestamps.py:batch_size1 and 4.Three of these fail on
main.claude-reviewwill fail as on #12 (the repository'sCLAUDE_CODE_OAUTH_TOKENsecret, see this comment).🤖 Generated with Claude Code
https://claude.ai/code/session_01TMXYMqgLAykqRApmbRfpTA
Generated by Claude Code