fix(silero): include prefix-padding pre-roll in VAD speech buffer frame#1636
Merged
Conversation
The AudioFrame emitted on START_OF_SPEECH / END_OF_SPEECH sliced off the prefix-padding samples but still reported `samplesPerChannel = speechBufferIndex`, so the frame's metadata claimed more samples than its data contained and downstream consumers (STT, transcription) lost the pre-roll context the surrounding buffer machinery is designed to preserve. Slice from 0 instead so data length matches samplesPerChannel and the prefix-padding pre-roll is delivered, matching the Python original. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: eea6a7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
toubatbrian
approved these changes
May 28, 2026
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
AudioFrameemitted onSTART_OF_SPEECH/END_OF_SPEECHin the silero VAD sliced off the prefix-padding samples (subarray(prefixPaddingSamples, speechBufferIndex)) but still reportedsamplesPerChannel = speechBufferIndex. Result: frame metadata claimed more samples than its data contained, and the pre-roll audio that the buffer machinery deliberately preserves was discarded before reaching downstream consumers (STT, transcription).0instead so data length matchessamplesPerChanneland the pre-roll is delivered. Matches the Python original (livekit-agents/livekit/agents/inference/vad.py:self._speech_buffer[:speech_buffer_index]).The same bug exists in
agents/src/inference/vad.tson thefeat/AGT-2520-multimodal-eoubranch and will be fixed there before that PR merges — the file does not yet exist on main.Test plan
pnpm buildsucceedspnpm testpassesSTART_OF_SPEECHAudioFrame data length equalssamplesPerChanneland includes pre-roll🤖 Generated with Claude Code