Repository navigation
fix(silero): keep activation/deactivation threshold pair consistent in update_options - #7735
iamdgarcia wants to merge 3 commits into
Conversation
…n update_options VAD.load(activation_threshold=x) derives deactivation_threshold as max(x - 0.15, 0.01) when not given, but VAD.update_options() and VADStream.update_options() replaced activation_threshold while keeping the previously derived deactivation_threshold. The same options produced different behavior depending on the entry point, and low activation values could leave deactivation above activation (inverted hysteresis). update_options now re-derives the paired default when activation_threshold is given without deactivation_threshold, matching load(). Applied to the silero plugin and to the same pattern in livekit.agents.inference.VAD. Also adds VAD.with_options() (issue livekit#7602): create a VAD reusing an existing ONNX inference session with new options, avoiding the GIL-holding session rebuild per call. Fixes livekit#7597, addresses livekit#7602
|
Good catch — Fixed in fa9a995→HEAD: |
|
All CI checks green on the cleaned branch (ruff ✅, unit-tests ✅, type-check ✅, blockguard ✅, release-gate ✅). Also removed from the branch: stray local test fixtures (7 wav files) and PR working notes that had leaked into the initial commit — the diff is now exactly the 3 intended files (silero |
a5e2aac to
c3f11f6
Compare
|
Updated the branch with current main (merge, no conflicts). All checks re-ran green: ruff ✅, unit-tests ✅, type-check (3.10/3.13) ✅, blockguard ✅, release-gate ✅, CLA ✅. Ready for review whenever you get a chance. |
7b713a2 to
c3f11f6
Compare
|
Friendly ping: still clean on c3f11f6 and CI re-verified green today (ruff, unit-tests, type-check 3.10/3.13, blockguard, release-gate). Ready for review whenever you get a chance; happy to adjust anything. |
Rebased onto main (post livekit#7285, livekit#7739). Un-stacked from the silero VAD branch (livekit#7735) so this PR carries only its own changes. Pipelines with manual_flush keep the livekit#7285 flush-first path; the reuse shortcut applies to plain streaming pipelines where a second final will never arrive.
|
Another friendly ping: still mergeable and CI green after the 1.8.11 release wave (no conflicts with current main), 11 days since my last note. Fixes #7597. Happy to rebase or adjust anything. |
|
Friendly ping: this has been green and mergeable for about two weeks now. Happy to rebase on main or adjust anything that would make review easier. |
Fixes #7597, addresses #7602.
VAD.load(activation_threshold=x)derivesdeactivation_threshold = max(x - 0.15, 0.01)when not given. ButVAD.update_options()/VADStream.update_options()replaced onlyactivation_threshold, keeping the previously derived deactivation threshold. Consequences (from the issue):update_options(activation_threshold=0.7)leavesdeactivation_threshold=0.35— speech ends later than configured;load(activation_threshold=0.7)would give 0.55. Same options, different VAD.update_options(activation_threshold=0.2)leaves deactivation above activation: the exit threshold can never take effect (inverted hysteresis).This changes the pair consistently in both the silero plugin and the
livekit.agents.inference.VADcopy, re-deriving the paired default only whenactivation_thresholdis given without an explicitdeactivation_threshold(explicit values always win, as before).Companion (#7602): adds
VAD.with_options(...)— build a VAD reusing the existing ONNX session with load()-style option derivation. The session is safe to share (eachstream()allocates its ownOnnxModelstate); this avoids the per-callInferenceSessionbuild that holds the GIL (~15 ms measured in the issue). Leftinference/vad.pywithout awith_optionstwin to keep the diff minimal — happy to add it if maintainers want symmetry there too.Tests: new
tests/test_silero_vad_options.py(6 tests, no real ONNX session needed for the options-logic); existingtests/test_vad.pypasses unchanged (8 tests, incl. real ONNX inference).Reviewer note: the behavior change is the fix — anyone relying on the stale derived deactivation gets the load()-consistent pair now. Flag in changelog if shipped in a minor.