refactor(talk): share audio-energy stats and speech-threshold gate across voice surfaces#109466
Merged
Conversation
…ross voice surfaces
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 17, 2026
…ross voice surfaces (openclaw#109466)
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.
What Problem This Solves
Three voice surfaces carried their own audio-energy math and speech-onset gating with drifting semantics: the voice-call plugin's μ-law RMS detector (
RealtimeMulawSpeechStartDetector+ a private G.711 decoder), the Google Meet local transport's PCM16 RMS/peak stats with inline barge-in threshold/cooldown logic, and no shared primitive in core at all. Any tuning or fix had to be re-derived per surface, and the μ-law decoder existed twice in the tree.Why This Change Was Made
Phase 2 of consolidating the voice/meeting stack (follows #109413). One primitive now lives in
src/talk/audio-energy.ts, exported throughopenclaw/plugin-sdk/realtime-voice:readPcm16AudioStats— RMS/peak over PCM16 (the Meet math, unchanged).calculateMulawRms— μ-law RMS with the lookup table derived from the canonicalmulawToPcmcodec; numerically identical to the deleted local decoder (same(mantissa << 3) + 132formula, verified against source; the 0.035 threshold behaves identically).createSpeechThresholdGate— one threshold/onset state machine expressing both consumers: voice-call's sustained-onset (2 loud frames, 12 quiet frames to rearm) and Meet's single-frame RMS-or-peak barge-in with cooldown and caller veto (onTrigger).Both consumers migrated; both local implementations deleted. Discord voice intentionally keeps its gateway speaking-events model (no energy VAD there).
User Impact
None intended: same triggers for the same audio at the same thresholds. Voice-call speech-start detection and Google Meet human barge-in behave as before.
Evidence
node scripts/run-vitest.mjs src/talk extensions/voice-call extensions/google-meet: 1003 tests passed (rerun green after rebase onto current main).pnpm plugin-sdk:surface:checkandplugin-sdk:apibaseline regenerated; budgets bumped with the standard annotations (+4 exports / +3 callables); docssdk-subpaths.md+sdk-migration.mdupdated.