Skip to main content
Version: 0.10.0

Type Alias: FsmnVoiceActivityDetector

FsmnVoiceActivityDetector = object

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:180

Voice activity detection task runner using the FSMN-VAD model.

Properties​

detectVoice()​

readonly detectVoice: (waveform, options?) => Promise<VadSegment[]>

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:196

Asynchronously detects speech segments within a mono waveform sampled at FSMN_VAD_SAMPLE_RATE_HZ.

Parameters​

waveform​

Float32Array

The input audio samples (16 kHz mono Float32 PCM).

options?​

VadOptions

Optional per-call overrides of the detection thresholds. See VadOptions.

Returns​

Promise<VadSegment[]>

A promise resolving to the detected speech segments, in seconds.

Throws​

With code RESOURCE_BUSY if the model is in use, or RESOURCE_DISPOSED if disposed.


detectVoiceOnStream()​

readonly detectVoiceOnStream: (chunk, options?) => VadEvent | undefined

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:217

Appends a live audio chunk to a bounded rolling window, runs detection over that window and reports a VadEvent when speech starts or stops, otherwise undefined. Designed to be driven straight from a recorder callback. Detection runs synchronously on the calling thread (a few ms).

Parameters​

chunk​

Float32Array

The newly captured audio samples (16 kHz mono Float32 PCM).

options?​

VadStreamOptions

Optional overrides of the detection thresholds and margin. See VadStreamOptions.

Returns​

VadEvent | undefined

'speechStart' or 'speechEnd' if state transitioned, otherwise undefined.

Throws​

With code RESOURCE_BUSY if the model is in use, or RESOURCE_DISPOSED if disposed.


detectVoiceWorklet()​

readonly detectVoiceWorklet: (waveform, options?) => VadSegment[]

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:202

Synchronous version of detectVoice to be executed directly on the caller or worklet thread.

Parameters​

waveform​

Float32Array

options?​

VadOptions

Returns​

VadSegment[]


dispose()​

readonly dispose: () => void

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:184

Releases all allocated native resources.

Returns​

void


resetStream()​

readonly resetStream: () => void

Defined in: extensions/speech/tasks/fsmnVoiceActivityDetection.ts:225

Clears the rolling window and speaking state used by detectVoiceOnStream.

Returns​

void