/** * SimpleVAD - Energy-based Voice Activity Detection * * This implementation uses audio energy analysis to detect speech without requiring * machine learning models. It's fast, requires no downloads, but less accurate than Silero VAD. * * Algorithm: * - Analyzes audio samples in real-time using Web Audio API * - Calculates RMS (Root Mean Square) energy level * - Detects speech when energy exceeds threshold * - Uses redemption frames to avoid flickering (brief silence during speech) */ /** * SimpleVAD configuration */ export interface SimpleVADConfig { /** MediaStream from microphone */ stream: MediaStream; /** Energy threshold for speech detection (0-1, default: 0.15) */ energyThreshold?: number; /** Sample rate in Hz (default: 16000) */ sampleRate?: number; /** FFT size for frequency analysis (default: 2048) */ fftSize?: number; /** Analysis interval in ms (default: 100) */ analysisInterval?: number; /** Minimum duration of silence (in frames) before speech is considered ended (default: 8) */ redemptionFrames?: number; /** Called when speech starts */ onSpeechStart?: () => void; /** Called when speech ends */ onSpeechEnd?: () => void; } /** * SimpleVAD class * Energy-based voice activity detection using Web Audio API */ export declare class SimpleVAD { private audioContext; private analyser; private microphone; private intervalId; private config; private stream; private isSpeaking; private silenceFrames; private isActive; constructor(config: SimpleVADConfig); /** * Start VAD processing */ start(): Promise; /** * Stop VAD processing */ stop(): Promise; /** * Pause VAD processing */ pause(): void; /** * Resume VAD processing */ resume(): void; /** * Check if currently speaking */ isSpeakingNow(): boolean; /** * Start the audio analysis loop */ private startAnalysis; /** * Analyze a single audio frame */ private analyzeFrame; /** * Calculate RMS (Root Mean Square) energy from frequency data * * @param dataArray - Frequency data array * @returns RMS energy value */ private calculateRMS; } //# sourceMappingURL=SimpleVAD.d.ts.map