Fix incorrect word timestamps for audio inputs longer than 60 seconds#29
Open
JamesVong wants to merge 1 commit intofacebookresearch:mainfrom
Open
Fix incorrect word timestamps for audio inputs longer than 60 seconds#29JamesVong wants to merge 1 commit intofacebookresearch:mainfrom
JamesVong wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
When ChunkEvents splits audio into chunks pointing to the same WAV file, each chunk has offset > 0 marking its position in the file. ExtractWordsFromAudio was using += start + offset, but whisperx times are already relative to the file start, so the correct conversion is += start - offset. This caused word timestamps to be inflated by 2x the offset for chunks after the first, which also inflated the CategoricalEvent duration, producing ~2x too many segments and a wrong time axis for any input longer than 60 seconds.
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.
Bug
ExtractWordsFromAudioproduces incorrect word timestamps for any input longer than 60 seconds (theChunkEventsmax_duration threshold).ChunkEventssplits long audio into chunks that reuse the same WAV file with a non-zerooffset, e.g. for a 96s video:WhisperX is called once on the full file, so word times are already relative to the file start. The existing formula:
double-counts the offset for chunk 2 (adds 120s instead of 0), shifting words at 90s → 210s.
This also inflates the CategoricalEvent duration computed in get_loaders, causing list_segments to generate ~2× too many segments, so a 96s video produces 215 segments spanning 0–214s instead of ~96.
Fix
This correctly converts from file-relative time to timeline-absolute time. For chunk 2 (start=60, offset=60): word at 90s → 90 + 60 − 60 = 90s ✓
Chunk 1 (start=0, offset=0) is unaffected.
Reproduction
I ran the events pipeline on a 96s video to confirm the fix:
The demo notebook (
tribe_demo.ipynb) uses a 52s Sintel clip which never triggers chunking, so this bug is not visible in the default demo.