Skip to content

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 sensitivityVADConfig.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

Properties

PropertyTypeDefault valueDescriptionDefined in
bargeIn?booleantrueWhether 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?number0.75Speech-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?booleantrue (when a vad config object is provided)Whether local VAD is active.src/core/types/config.ts:386
engine?VADEngineundefinedA 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?number200Consecutive speech required before a segment starts, in ms. Remarks Debounces transient noise (door slams, keyboard clatter).src/core/types/config.ts:442
modelUrl?stringundefinedWhere 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?number800Silence 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?number0.5Speech-probability threshold in [0, 1] while the agent is not speaking.src/core/types/config.ts:419

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency