Skip to content

fix(vad): add support for vad reset directly without stream close#5687

Open
chenghao-mou wants to merge 5 commits intomainfrom
chenghao/fix/vad-reset-with-stt
Open

fix(vad): add support for vad reset directly without stream close#5687
chenghao-mou wants to merge 5 commits intomainfrom
chenghao/fix/vad-reset-with-stt

Conversation

@chenghao-mou
Copy link
Copy Markdown
Member

@chenghao-mou chenghao-mou commented May 8, 2026

add vad stream reset method directly so that we don't have to close the stream or task

resetting directly with a new resampler and buffer zero-fill should take less than 0.1ms.

this closes #5674

add vad stream reset method directly so that we don't have to close the stream or task

this closes #5674
@chenghao-mou chenghao-mou requested a review from a team May 8, 2026 14:49
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment thread livekit-agents/livekit/agents/vad.py Outdated

Only effective when the underlying VAD advertises
`VADCapabilities.supports_reset`. For implementations that do not
support reset, the sentinel is silently dropped; callers that need a
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.

should we raise an error when reset is not supported?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good point. I'll add that.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

nonlocal input_copy_remaining_fract, extra_inference_time

self._model.reset()
self._exp_filter.reset()
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.

🟑 ExpFilter.reset() called with no arguments is a no-op, leaving stale filter state after VAD reset

In _reset_state(), self._exp_filter.reset() is called at line 325 with no arguments. However, ExpFilter.reset() (livekit-agents/livekit/agents/utils/exp_filter.py:21-36) only updates fields whose corresponding parameter passes the is_given() check. Since all parameters default to NOT_GIVEN, none of the if is_given(...) branches execute β€” the call is a complete no-op. The internal self._filtered value (which holds the smoothed probability from the previous speech segment) is carried into the next segment.

After a VAD stream reset, the first inference probability will be blended with the stale filter value (filtered = 0.35 * old + 0.65 * new with alpha=0.35) instead of being accepted directly as with a fresh stream. This can cause slightly delayed or premature speech detection for the first ~1–2 inference windows after reset.

Suggested change
self._exp_filter.reset()
self._exp_filter = utils.ExpFilter(alpha=0.35)
Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

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.

Bug: update_vad() on STT EOT introduces ~600ms deaf window because the new VAD task waits for the old one to shut down

2 participants