Skip to content

refactor(talk): share audio-energy stats and speech-threshold gate across voice surfaces#109466

Merged
steipete merged 1 commit into
mainfrom
refactor/talk-speech-onset
Jul 17, 2026
Merged

refactor(talk): share audio-energy stats and speech-threshold gate across voice surfaces#109466
steipete merged 1 commit into
mainfrom
refactor/talk-speech-onset

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 through openclaw/plugin-sdk/realtime-voice:

  • readPcm16AudioStats — RMS/peak over PCM16 (the Meet math, unchanged).
  • calculateMulawRms — μ-law RMS with the lookup table derived from the canonical mulawToPcm codec; numerically identical to the deleted local decoder (same (mantissa << 3) + 132 formula, 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).
  • New unit tests for the primitive: silence, tone burst, threshold edge, sustained-onset, silence-rearm, veto, and cooldown re-trigger cases.
  • pnpm plugin-sdk:surface:check and plugin-sdk:api baseline regenerated; budgets bumped with the standard annotations (+4 exports / +3 callables); docs sdk-subpaths.md + sdk-migration.md updated.
  • Autoreview (Codex gpt-5.6-sol, xhigh): clean, no actionable findings.
  • Net production LOC across the three areas: +2 (new shared module pays for both deletions).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: voice-call Channel integration: voice-call scripts Repository scripts plugin: google-meet size: M maintainer Maintainer-authored PR labels Jul 17, 2026
@steipete
steipete merged commit 92146f9 into main Jul 17, 2026
158 of 163 checks passed
@steipete
steipete deleted the refactor/talk-speech-onset branch July 17, 2026 01:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call docs Improvements or additions to documentation maintainer Maintainer-authored PR plugin: google-meet scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant