@ericedouard/vad-node-realtime
Version:
Powerful, user-friendly realtime voice activity detector (VAD) for node
63 lines • 2.28 kB
TypeScript
import type { OrtOptions } from "./common";
import { type FrameProcessorOptions } from "./common/frame-processor";
import { type SpeechProbabilities } from "./common/models";
export type ModelVersion = "v5" | "legacy";
export declare const DEFAULT_MODEL: ModelVersion;
/**
* Callbacks for real-time VAD events
*/
export interface RealTimeVADCallbacks {
onFrameProcessed: (probabilities: SpeechProbabilities, frame: Float32Array) => void;
onVADMisfire: () => void;
onSpeechStart: () => void;
onSpeechRealStart: () => void;
onSpeechEnd: (audio: Float32Array) => void;
}
/**
* Options for RealTimeVAD in Node environment
*/
export interface RealTimeVADOptions extends FrameProcessorOptions, RealTimeVADCallbacks, OrtOptions {
/** Sample rate of the incoming audio; will be resampled to 16000Hz internally */
sampleRate: number;
/** Which Silero model to use: V5 or legacy */
model?: ModelVersion;
}
/**
* Build default options based on chosen model
*/
export declare function getDefaultRealTimeVADOptions(model?: ModelVersion): RealTimeVADOptions;
/**
* RealTimeVAD processes raw audio buffers, frames, and emits events
*/
export declare class RealTimeVAD {
private options;
private frameProcessor;
private modelInstance;
private buffer;
private frameSize;
private active;
private resampler;
/**
* Construct a new instance with provided options and loaded model
*/
protected constructor(options: RealTimeVADOptions, modelInstance: any);
/**
* Create and initialize a RealTimeVAD instance
*/
static new(ort: any, modelFetcher: () => Promise<ArrayBuffer>, opts?: Partial<RealTimeVADOptions>): Promise<RealTimeVAD>;
/** Start processing incoming frames */
start(): void;
/** Pause processing; may emit end-segment on pause */
pause(): void;
/** Feed raw audio (any sample rate) into the VAD */
processAudio(audioData: Float32Array): Promise<void>;
/** Flush any remaining audio and end segment */
flush(): Promise<void>;
/** Reset internal state */
reset(): void;
/** Handle events emitted by the frame processor */
private handleEvent;
/** Clean up resources */
destroy(): void;
}
//# sourceMappingURL=real-time-vad.d.ts.map