Fix word-level timestamp overflow in Whisper chunked transcription#1483
Open
neonwatty wants to merge 1 commit intohuggingface:mainfrom
Open
Fix word-level timestamp overflow in Whisper chunked transcription#1483neonwatty wants to merge 1 commit intohuggingface:mainfrom
neonwatty wants to merge 1 commit intohuggingface:mainfrom
Conversation
…uggingface#1357) Clamp word-level timestamps to the actual chunk_len to prevent timestamps from exceeding audio duration when the model outputs timestamps near the 30s boundary for shorter final chunks.
rossinek
added a commit
to rossinek/transformers.js
that referenced
this pull request
Feb 18, 2026
…r chunked transcription
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
chunk_lento prevent timestamps from exceeding audio durationRoot Cause
When using
chunk_length_s=30with word-level timestamps (return_timestamps: 'word'), the Whisper model can output timestamps up to ~29.98s (the maximum representable timestamp giventime_precision = 30/1500 = 0.02). For a final chunk shorter than 30s, these timestamps would be added to the accumulatedtime_offset, causing the final timestamps to exceed the actual audio duration.Solution
Track the actual
chunk_lenfrom the stride information and clamp raw token timestamps before addingtime_offset. This ensures word-level timestamps never exceed the audio duration while preserving the existing behavior for segment-level timestamps.Test plan