Skip to content

Add word-level timestamps to batched decoding - #14

Merged
CodeWithBehnam merged 1 commit into
mainfrom
claude/lucid-franklin-gsu7v4
Sep 30, 2026
Merged

CodeWithBehnam merged 1 commit into
mainfrom
claude/lucid-franklin-gsu7v4

Conversation

@CodeWithBehnam

Copy link
Copy Markdown
Owner

What does this PR do?

Closes #4.

  • add_word_timestamps was only called when batch_size=1, so word_timestamps=True did nothing with batching, which is 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 spectrogram, using that window's seek (fixed in Keep text after the last timestamp pair in batched decoding #13) for the time offset.
  • hallucination_silence_threshold needs window-by-window seeking, which a batch can't do. With batch_size > 1 it now warns instead of being dropped silently, and the docstring says so.
  • Test helpers: random_whisper() builds a small random-weight model, so the alignment pass in tests is real (cross-attention + DTW).

How was this tested?

  • Tested with audio file(s)
  • Ran existing tests (pytest): 24 passed
  • Tested CLI (vayu audio.mp3)

tests/test_word_timestamps.py:

  • Checks that words exist, add up to the segment text, and fall inside their own window, for batch_size 1 and 4.
  • Checks each batched window's words use that window's offset.
  • Checks the warning appears with batching and not without.

Three of these fail on main.

claude-review will fail as on #12 (the repository's CLAUDE_CODE_OAUTH_TOKEN secret, see this comment).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TMXYMqgLAykqRApmbRfpTA


Generated by Claude Code

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
@CodeWithBehnam
CodeWithBehnam merged commit 7195d7f into main Sep 30, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Word-level timestamps are silently skipped when batch_size > 1

2 participants