Skip to content

fix: keep 0.3 s of audio before an utterance, so its first word is not clipped - #188

Open
amahpour wants to merge 1 commit into
joinly-ai:mainfrom
amahpour:fix/utterance-preroll
Open

amahpour wants to merge 1 commit into
joinly-ai:mainfrom
amahpour:fix/utterance-preroll

Conversation

@amahpour

@amahpour amahpour commented Nov 5, 2026

Copy link
Copy Markdown

The first word of an utterance is often clipped, and with hotwords set Whisper can turn the clipped word into a hotword.

Problem. BasePaddedVAD keeps one 32 ms window from before the first window the VAD calls speech, and Silero flags speech late. On a recorded Zoom call (24 lines, three Kokoro voices) it was a median of 73 ms after the first audible sound, p90 214 ms, max 378 ms. So the piece WhisperSTT gets starts partway into the first word. With the room's names as hotwords, "Our upload page keeps failing on big files" came out as "Claude page keeps failing on big files" (the first hotword), and "Claude, what is the upload limit…" lost "Claude". It is not the model: large-v3-turbo makes the same mistake.

Change. DefaultTranscriptionController keeps the last windows of non-speech audio while no utterance is open. When an utterance starts it puts them at the front of that utterance's window queue, marked as speech (WhisperSTT._buffer_windows only starts its buffer on a speech window), with their own time_ns and speaker. A new argument, utterance_preroll_seconds, sets how much: 0.3 by default (ten 32 ms windows), 0 turns it off.

It is in the controller and not in BasePaddedVAD on purpose. Keeping k windows back in the VAD would delay every non-speech window, and so the end of every utterance, by k windows. The controller already has the audio, so nothing waits. utterance_start, last_speech and no_speech_event still come from the VAD's own windows, because the pre-roll goes straight into the queue.

Measurement. The recording was replayed through the unmodified SileroVAD, DefaultTranscriptionController._vad_worker and WhisperSTT._buffer_windows (base, 4 CPUs, 3 runs at four 8 ms offsets, to stand in for a live call's jitter). A line counts as right when switchboard's name matcher picks the agent that was called; delay is from the end of speech to the line's last piece being transcribed.

right agent (of 17 call-outs) false wakes (of 7 lines that call nobody) words wrong extra delay (median / p90)
utterance_preroll_seconds=0 (as before) 14.8 1 8.8% n/a
0.3 (the default) 16 0 3.5% +0.01 s / +0.07 s

The replay with the argument at 0 cuts the same pieces as unmodified joinly (identical start, end and emit times at every offset).

Not covered. A piece that starts inside an utterance, after a pause shorter than utterance_tail_seconds, still starts at the VAD's flag as before. That was 4 of 30 pieces in the recording, and a ring for them in WhisperSTT._buffer_windows changed the words wrong from 3.5% to 3.3%, so it is not in this PR.

Test. tests/test_transcription_controller.py runs the real BasePaddedVAD and the controller over a scripted call, with an STT that records what it is given. It checks that an utterance starts with the audio before its speech, that those windows are marked as speech and keep their time and speaker, that nothing is added inside an utterance or repeated across two, that a short gap does not reach back into the last utterance, that 0 turns it off, and that WhisperSTT._buffer_windows starts its first piece at the pre-roll. Seven of its twelve tests fail without the change.

🤖 Generated with Claude Code

…irst word is not clipped

The VAD flags speech late (Silero: median about 70 ms, up to about 380 ms
after the first audible sound) and BasePaddedVAD keeps one 32 ms window
from before it. The piece the STT gets starts partway into the first word,
and with hotwords Whisper turns the clipped word into one of them.

The transcription controller now keeps the last windows of audio while no
utterance is open, and puts them at the front of the next utterance's
queue, marked as speech (WhisperSTT starts its buffer on a speech window),
with their own times and speakers. The new utterance_preroll_seconds
argument sets how much: 0.3 by default, 0 turns it off. No waiting is
added: the audio has already arrived.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
amahpour added a commit to amahpour/switchboard that referenced this pull request Nov 5, 2026
The pre-roll fix is now offered upstream as joinly-ai/joinly#188. Name it where
the docs describe the fix, the way joinly-ai/joinly#187 is named for the Zoom
fix: DEPLOY.md (the bot, Helm and Kubernetes sections), the meetings guide,
DESIGN.md section 52, the change note and the self-test skill. The pinned fork
commit and its sha256 are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant