Skip to content

fix(audio): discard pending resampler audio on buffer reset - #7405

Open
YaoxinHuang wants to merge 2 commits into
livekit:mainfrom
YaoxinHuang:fix/audio-array-buffer-reset-resampler
Open

YaoxinHuang wants to merge 2 commits into
livekit:mainfrom
YaoxinHuang:fix/audio-array-buffer-reset-resampler

Conversation

@YaoxinHuang

Copy link
Copy Markdown
Contributor

AudioArrayBuffer.reset() clears the NumPy buffer but keeps the resampler and its delayed samples. After reset, pushing silence can emit audio from the previous segment. The interruption detector resets this buffer at agent-speech boundaries.

Discard the resampler on reset so the next frame starts a fresh resampling stream. Tests use the real RTC resampler at 8, 24, and 48 kHz and check that previously buffered audio does not leak into the next segment; a small tolerance accommodates native PCM dithering.

Validation:

  • python -m pytest tests/test_utils/test_audio_array_buffer.py --unit -q: 49 passed. The three new cases fail before the fix; the existing 46 pass.
  • Ruff check/format on both changed files and repository-wide Ruff check pass.
  • python -m mypy --platform linux -m livekit.agents.utils.audio: passes.

Repository-wide formatting reports 15 pre-existing files outside this diff. The full provider suite and all-plugin type check were not run. No model weights or service credentials were used.

Prepared and tested with Codex.

Start a fresh resampling stream after reset so audio from the previous speech segment cannot leak into the next segment.
Use the native RTC resampler at 8, 24, and 48 kHz and allow a small tolerance for PCM dithering.
@YaoxinHuang
YaoxinHuang requested a review from a team as a code owner September 23, 2026 02:26
@CLAassistant

CLAassistant commented Sep 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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.

2 participants