Skip to content

Fix incorrect word timestamps for audio inputs longer than 60 seconds#29

Open
JamesVong wants to merge 1 commit intofacebookresearch:mainfrom
JamesVong:fix/extract-words-chunk-offset
Open

Fix incorrect word timestamps for audio inputs longer than 60 seconds#29
JamesVong wants to merge 1 commit intofacebookresearch:mainfrom
JamesVong:fix/extract-words-chunk-offset

Conversation

@JamesVong
Copy link
Copy Markdown

@JamesVong JamesVong commented Apr 5, 2026

Bug

ExtractWordsFromAudio produces incorrect word timestamps for any input longer than 60 seconds (the ChunkEvents max_duration threshold).

ChunkEvents splits long audio into chunks that reuse the same WAV file with a non-zero offset, e.g. for a 96s video:

start offset filepath
Chunk 1 0 0 audio.wav
Chunk 2 60 60 audio.wav

WhisperX is called once on the full file, so word times are already relative to the file start. The existing formula:

transcript["start"] += audio_event.start + audio_event.offset 

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

transcript["start"] += audio_event.start - audio_event.offset

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:

Chunk (start=0.0, offset=0.0):
  OLD: word times 0.071s – 93.702s
  NEW: word times 0.071s – 93.702s   ← unchanged

Chunk (start=60.0, offset=60.0):
  OLD: word times 120.071s – 213.702s  ← wrong
  NEW: word times 0.071s –  93.702s   ← correct

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.

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.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant