VADConfig
Configuration for local voice activity detection.
Defined in: src/core/types/config.ts:380
Configuration for local voice activity detection.
Remarks
When enabled, a local VAD model (Silero by default, running on ONNX Runtime) scores the microphone audio directly, independent of the STT provider. This gives the pipeline:
- Provider-independent barge-in — playback is interrupted as soon as sustained local speech is detected, without waiting for the STT provider to return text.
- False-barge-in resistance — a higher bargeInThreshold applies while the agent is speaking, so TTS echo leaking into the microphone has to clear a higher bar; VADConfig.minSpeechDurationMs debounces transient noise.
- Configurable end-of-turn sensitivity — VADConfig.silenceDurationMs controls how much silence ends a speech segment (
vad.speechEnd).
Requires the onnxruntime-web (browser) or onnxruntime-node (server) optional peer dependency unless a custom VADConfig.engine is supplied. Only available when the input provider is separate from the STT provider (multi-role inputs like NativeSTT manage their own microphone, so the SDK never sees the raw audio).
Example
const agent = new CompositeVoice({
providers: [...],
vad: {
enabled: true,
modelUrl: '/models/silero_vad_v5.onnx',
bargeIn: true,
silenceDurationMs: 600,
},
});
agent.on('vad.speechStart', ({ probability }) => showSpeakingIndicator());
agent.on('vad.speechEnd', ({ durationMs }) => hideSpeakingIndicator());
See
- CompositeVoiceConfig.vad for where this is used
- TurnTakingConfig for the complementary echo-avoidance system
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
bargeIn? | boolean | true | Whether detected speech triggers barge-in while the agent is speaking or thinking. Remarks When false, VAD only emits vad.speechStart / vad.speechEnd events and leaves interruption to the STT provider’s speech events. | src/core/types/config.ts:466 |
bargeInThreshold? | number | 0.75 | Speech-probability threshold applied while the agent is speaking. Remarks The classic false-barge-in bug is the agent’s own TTS audio echoing into the microphone and interrupting itself. Requiring a higher probability during playback filters that echo while still letting a real interjection through. | src/core/types/config.ts:432 |
enabled? | boolean | true (when a vad config object is provided) | Whether local VAD is active. | src/core/types/config.ts:386 |
engine? | VADEngine | undefined | A custom VAD engine implementation. Remarks Defaults to the built-in Silero engine. Supply your own VADEngine to use a different model or to stub detection in tests. | src/core/types/config.ts:396 |
minSpeechDurationMs? | number | 200 | Consecutive speech required before a segment starts, in ms. Remarks Debounces transient noise (door slams, keyboard clatter). | src/core/types/config.ts:442 |
modelUrl? | string | undefined | Where to load the Silero model from (URL, or filesystem path in Node). Remarks Defaults to a pinned public CDN copy — self-host for production. Ignored when VADConfig.engine is supplied. | src/core/types/config.ts:405 |
runtime? | "auto" | "web" | "node" | 'auto' (browser → onnxruntime-web, otherwise onnxruntime-node) | Which ONNX Runtime package the built-in engine loads. | src/core/types/config.ts:412 |
silenceDurationMs? | number | 800 | Silence required before a segment ends, in ms. Remarks The end-of-turn sensitivity knob: lower values end turns faster (snappier, more likely to cut off slow speakers), higher values are more patient. | src/core/types/config.ts:454 |
threshold? | number | 0.5 | Speech-probability threshold in [0, 1] while the agent is not speaking. | src/core/types/config.ts:419 |