Skip to content

VADProcessor

Converts pipeline audio into VAD frames and tracks speech segments.

Defined in: src/core/vad/VADProcessor.ts:106

Converts pipeline audio into VAD frames and tracks speech segments.

Remarks

Feed it every input chunk via push; it handles decoding (linear16 / mulaw / alaw), stereo downmix, resampling to the engine’s rate, framing, and segment detection. Processing is serialized internally, so push can be called synchronously from audio callbacks.

Example

const processor = new VADProcessor(engine, { silenceDurationMs: 600 });
processor.configure({ sampleRate: 48000, encoding: 'linear16', channels: 1, bitDepth: 16 });
processor.onSpeechStart(({ probability }) => console.log('speech!', probability));
processor.onSpeechEnd(({ durationMs }) => console.log(`spoke for ${durationMs}ms`));

input.onAudio((chunk) => processor.push(chunk.data));

See

Constructors

Constructor

new VADProcessor(
   engine, 
   options?, 
   logger?): VADProcessor;

Defined in: src/core/vad/VADProcessor.ts:152

Parameters

ParameterType
engineVADEngine
optionsVADProcessorOptions
logger?Logger

Returns

VADProcessor

Accessors

isSpeaking

Get Signature

get isSpeaking(): boolean;

Defined in: src/core/vad/VADProcessor.ts:163

Whether a speech segment is currently in progress.

Returns

boolean

Methods

configure()

configure(metadata): void;

Defined in: src/core/vad/VADProcessor.ts:175

Describe the incoming audio format.

Parameters

ParameterType
metadataAudioMetadata

Returns

void

Remarks

Call before the first push — typically with the input provider’s getMetadata(). Chunks pushed before configuration are dropped.


flush()

flush(): Promise<void>;

Defined in: src/core/vad/VADProcessor.ts:248

Wait for all pushed audio to finish processing.

Returns

Promise<void>

Remarks

Primarily for tests and orderly shutdown.


onSpeechEnd()

onSpeechEnd(callback): void;

Defined in: src/core/vad/VADProcessor.ts:202

Register a callback for confirmed speech ends.

Parameters

ParameterType
callback(info) => void

Returns

void


onSpeechStart()

onSpeechStart(callback): void;

Defined in: src/core/vad/VADProcessor.ts:197

Register a callback for confirmed speech starts.

Parameters

ParameterType
callback(info) => void

Returns

void


push()

push(data): void;

Defined in: src/core/vad/VADProcessor.ts:216

Feed one chunk of input audio.

Parameters

ParameterTypeDescription
dataArrayBufferRaw audio bytes in the configured format.

Returns

void

Remarks

Non-blocking: decoding, resampling, and inference run on an internal serial queue. Errors are logged and swallowed — VAD is an enhancement and must never take down the audio path.


reset()

reset(): void;

Defined in: src/core/vad/VADProcessor.ts:289

Clear buffered audio and segment state (call between sessions).

Returns

void

Remarks

If a speech segment is open, it is closed silently — no onSpeechEnd fires, because the session ending is not an end-of-turn signal.


setThresholdOverride()

setThresholdOverride(threshold): void;

Defined in: src/core/vad/VADProcessor.ts:192

Temporarily require a different entry threshold.

Parameters

ParameterTypeDescription
thresholdnumber | nullThe replacement entry threshold, or null to restore the configured one.

Returns

void

Remarks

The pipeline sets this to the configured barge-in threshold while the agent is speaking (echo resistance) and clears it with null when playback stops.

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency