Skip to content

Fix voice barge-in cutting off the opening greeting - #44

Merged
brentrager merged 2 commits into
mainfrom
fix-voice-bargein-debounce
Jul 29, 2026
Merged

Fix voice barge-in cutting off the opening greeting#44
brentrager merged 2 commits into
mainfrom
fix-voice-bargein-debounce

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

The voice agent's opening greeting cuts itself off mid-sentence, every time.

Root cause

Barge-in fired on a single mic frame over the RMS threshold (voice-session.ts:422). The capture worklet posts 128-sample frames = ~2.67ms at 48kHz. Browser echo cancellation is imperfect on speakers, so residual echo of the greeting (the loudest, longest agent audio) — or a cough, or a noise blip — crosses RMS 0.02 for one frame and instantly sends interrupt, aborting the greeting playback.

Fix

Require ~200ms of sustained above-threshold audio before barge-in fires (new bargeInMinMs option, default 200). Real speech crosses it easily; transient echo/noise blips don't. The accumulator resets on any quiet frame (echo is bursty) and on each new agent utterance.

Time-based (samples.length / sampleRate), so it's correct for both the AudioWorklet (128-sample) and ScriptProcessor (4096-sample) capture paths.

Tests

  • Sustained ≥200ms speech interrupts (updated existing test)
  • A short 50ms blip does NOT interrupt (the greeting-cutoff case)
  • Intermittent blips separated by quiet never accumulate
  • All 30 voice-session tests pass; typecheck + build clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01ULQ7QeEUq72vpU57ubzanJ

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dea8f51

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/chat-widget Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

brentrager and others added 2 commits July 29, 2026 16:58
Add CLAUDE.md project guide, .claude/settings.json hooks config,
and enforce-worktree.sh to prevent feature work on main branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Barge-in fired on a single ~2.67ms mic frame over the RMS threshold, so
residual acoustic echo from the greeting (browser AEC is imperfect on
speakers), a cough, or a noise blip interrupted the agent mid-sentence —
most visibly, the opening greeting never finished. Now require ~200ms of
sustained above-threshold audio before barge-in (bargeInMinMs, default
200); real speech crosses it easily, transient blips don't. Run resets on
any quiet frame and on each new agent utterance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULQ7QeEUq72vpU57ubzanJ
@brentrager
brentrager force-pushed the fix-voice-bargein-debounce branch from dd98e51 to dea8f51 Compare July 29, 2026 20:59
@brentrager
brentrager merged commit a5225bc into main Jul 29, 2026
1 check passed
@brentrager
brentrager deleted the fix-voice-bargein-debounce branch July 29, 2026 21:00
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.

1 participant