createBargeInGuard (calls/barge-in-guard.ts)

vellum-assistant · assistant/src/calls/barge-in-guard.ts · typescript · MIT
voice, Voice / Speech

Pure guard that tracks sustained speech to trigger barge‑in, exposing a simple API.

// Source: https://github.com/vellum-ai/vellum-assistant | License: MIT | Copyright 2025 Vellum AI
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * The sustained-speech barge-in guard, shared by the live-voice session and
 * the phone media-stream path.
 *
 * A single above-gate audio chunk is not an interruption: brief TTS bleed
 * through imperfect echo cancellation, a cough, a line click. Speech has to
 * accumulate to `minSpeechMs` before the assistant is cut off. Short gaps
 * inside a run are tolerated (a browser's half-duplex echo canceller ducks
 * the near-end voice into intermittent above-gate chunks; a phone line
 * drops frames), but a longer continuous silence, or a run that is mostly
 * silence, resets it, so sparse periodic blips can never sum into a
 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key