voice-pipeline/HardCutBargeinHandler.ts

agentos · src/io/voice-pipeline/HardCutBargeinHandler.ts · typescript · Apache-2.0
voice

* @module voice-pipeline/HardCutBargeinHandler Implements a hard-cut barge-in policy: when the user speaks over TTS output for at least `HardCutBargeinHandlerOptions.minSpeechMs` milliseconds, playback is stopped immediately with no fade-out. Short detections below the threshold

// Source: https://github.com/framerslab/agentos | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * @module voice-pipeline/HardCutBargeinHandler
 *
 * Implements a hard-cut barge-in policy: when the user speaks over TTS output
 * for at least `HardCutBargeinHandlerOptions.minSpeechMs` milliseconds,
 * playback is stopped immediately with no fade-out. Short detections below the
 * threshold are treated as accidental noise and ignored.
 *
 * ## Why 300 ms default threshold?
 *
 * The 300 ms threshold was chosen to filter out common non-speech audio events
 * that trigger false barge-in detections:
 *
 * - **Lip smacks**: Typically 50-150 ms of energy.
 * - **Breaths/sighs**: Typically 100-250 ms of energy.
 * - **Coughs/sneezes**: Short burst 100-20

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

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

Get a free API key