@speechly/browser-client
Version:
JavaScript client for Speechly Streaming API
33 lines (32 loc) • 1.51 kB
TypeScript
import { VadOptions } from '../client';
/**
* Adaptive energy threshold voice activity detection (VAD) implementation.
* It can be used to enable hands-free operation of the SLU decoder.
*
* When enough frames with a signal stronger than SignalToNoiseDb have been detected, IsSignalDetected goes true. When enough silent frames have been detected, IsSignalDetected goes false after the sustain time.
* Use its public fields to configure the static noise gate level, signal-to-noise level, activation/deactivation treshold (ratio of signal to silent frames) and the signal sustain time.
* The background noise level gradually adapts when no signal is detected.
*
* IsSignalDetected can be used to drive SpeechlyClient's StartContext and StopContext automatically by setting ControlListening true.
* @internal
*/
declare class EnergyTresholdVAD {
isSignalDetected: boolean;
signalDb: number;
noiseLevelDb: number;
vadOptions: VadOptions;
readonly frameMillis: number;
private energy;
private baselineEnergy;
private loudFrameBits;
private vadSustainMillisLeft;
constructor(frameMillis: number, vadOptions: VadOptions);
adjustVadOptions(vadOptions: Partial<VadOptions>): void;
resetVAD(): void;
processFrame(floats: Float32Array, start?: number, length?: number, eos?: boolean): void;
private determineNewSignalState;
private adaptBackgroundNoise;
private pushFrameHistory;
private countLoudFrames;
}
export default EnergyTresholdVAD;