### Initialize and Use RealTimeVAD for Voice Commands Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt This example shows how to initialize RealTimeVAD, start listening for speech, process audio chunks, and handle speech start/end events for command execution. Ensure audio is 16kHz mono for optimal performance. ```typescript import { RealTimeVAD, utils } from 'avr-vad'; import * as fs from 'fs'; class VoiceCommandDetector { private vad: RealTimeVAD | null = null; private isListening = false; async initialize() { this.vad = await RealTimeVAD.new({ model: 'v5', sampleRate: 16000, positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35, minSpeechFrames: 9, onSpeechStart: () => { console.log('[VAD] Possible speech detected...'); }, onSpeechRealStart: () => { console.log('[VAD] Speech confirmed, recording...'); this.onRecordingStarted(); }, onSpeechEnd: async (audio) => { console.log(`[VAD] Speech ended: ${audio.length} samples`); await this.processVoiceCommand(audio); }, onVADMisfire: () => { console.log('[VAD] False positive, ignoring'); }, onFrameProcessed: (probs) => { // Optional: real-time probability logging if (probs.isSpeech > 0.3) { process.stdout.write(`\r[VAD] Speech: ${(probs.isSpeech * 100).toFixed(1)}%`); } } }); console.log('[VoiceCommand] Initialized successfully'); } async startListening() { if (!this.vad) throw new Error('Not initialized'); this.isListening = true; this.vad.start(); console.log('[VoiceCommand] Listening for commands...'); } async processAudioChunk(audioChunk: Float32Array) { if (!this.vad || !this.isListening) return; await this.vad.processAudio(audioChunk); } private onRecordingStarted() { // Update UI, start visual feedback, etc. } private async processVoiceCommand(audio: Float32Array) { // Save audio for debugging const wavBuffer = utils.encodeWAV(audio, 1, 16000, 1, 16); fs.writeFileSync('last_command.wav', Buffer.from(wavBuffer)); // Send to speech recognition service const transcript = await this.transcribeAudio(audio); console.log(`[VoiceCommand] Transcript: "${transcript}"`); // Execute command await this.executeCommand(transcript); } private async transcribeAudio(audio: Float32Array): Promise { // Your speech-to-text implementation return 'example command'; } private async executeCommand(transcript: string) { // Your command processing logic console.log(`[VoiceCommand] Executing: ${transcript}`); } async stopListening() { if (!this.vad) return; this.isListening = false; this.vad.pause(); await this.vad.flush(); console.log('[VoiceCommand] Stopped listening'); } async destroy() { if (this.vad) { await this.vad.destroy(); this.vad = null; } console.log('[VoiceCommand] Cleaned up'); } } // Usage const detector = new VoiceCommandDetector(); await detector.initialize(); await detector.startListening(); // In your audio input callback: // await detector.processAudioChunk(audioFrame); // When done: // await detector.stopListening(); // await detector.destroy(); ``` -------------------------------- ### Prepare for Installation Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Builds the project before npm install. This script runs automatically. ```bash npm run prepare ``` -------------------------------- ### Install avr-vad Package Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Install the avr-vad package using npm. ```bash npm install avr-vad ``` -------------------------------- ### Build Project Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Builds the project using npm. Ensure Node.js and TypeScript are installed. ```bash npm run build ``` -------------------------------- ### Real-time VAD Processing Example Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Initialize and use the RealTimeVAD for processing audio frames in real-time. Ensure audio frames are Float32Array of 1536 samples at 16kHz. Clean up resources using vad.destroy() when done. ```typescript import { RealTimeVAD } from 'avr-vad'; // Initialize the VAD with default options (Silero v5 model) const vad = await RealTimeVAD.new({ model: 'v5', // or 'legacy' positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35, preSpeechPadFrames: 1, redemptionFrames: 8, frameSamples: 1536, minSpeechFrames: 3 }); // Process audio frames in real-time const audioFrame = getAudioFrameFromMicrophone(); // Float32Array of 1536 samples at 16kHz const result = await vad.processFrame(audioFrame); console.log(`Speech probability: ${result.probability}`); console.log(`Speech detected: ${result.msg === 'SPEECH_START' || result.msg === 'SPEECH_CONTINUE'}`); // Clean up when done vad.destroy(); ``` -------------------------------- ### Get Default Real-Time VAD Options Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Retrieve default configuration options for Silero VAD models. Use 'v5' for recommended settings or 'legacy' for older models. Options can be overridden. ```typescript import { getDefaultRealTimeVADOptions, DEFAULT_MODEL } from 'avr-vad'; // Get default options for v5 model (recommended) const v5Options = getDefaultRealTimeVADOptions('v5'); console.log('V5 defaults:', { frameSamples: v5Options.frameSamples, // 512 positiveSpeechThreshold: v5Options.positiveSpeechThreshold, // 0.5 negativeSpeechThreshold: v5Options.negativeSpeechThreshold, // 0.35 preSpeechPadFrames: v5Options.preSpeechPadFrames, // 3 redemptionFrames: v5Options.redemptionFrames, // 24 minSpeechFrames: v5Options.minSpeechFrames, // 9 sampleRate: v5Options.sampleRate // 16000 }); // Get default options for legacy model const legacyOptions = getDefaultRealTimeVADOptions('legacy'); console.log('Legacy defaults:', { frameSamples: legacyOptions.frameSamples, // 1536 preSpeechPadFrames: legacyOptions.preSpeechPadFrames, // 1 redemptionFrames: legacyOptions.redemptionFrames, // 8 minSpeechFrames: legacyOptions.minSpeechFrames // 3 }); // DEFAULT_MODEL is 'v5' console.log(`Default model: ${DEFAULT_MODEL}`); // Override specific options while keeping defaults const customOptions = { ...getDefaultRealTimeVADOptions('v5'), positiveSpeechThreshold: 0.6, // More strict negativeSpeechThreshold: 0.45, onSpeechEnd: (audio) => handleSpeech(audio) }; const vad = await RealTimeVAD.new(customOptions); ``` -------------------------------- ### Non-Real-time VAD Processing Example Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Initialize and use NonRealTimeVAD for batch processing of audio data. Load audio data as a Float32Array at 16kHz. Retrieve speech segments using getSpeechSegments() and clean up with vad.destroy(). ```typescript import { NonRealTimeVAD } from 'avr-vad'; // Initialize for batch processing const vad = await NonRealTimeVAD.new({ model: 'v5', positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35 }); // Process entire audio buffer const audioData = loadAudioData(); // Float32Array at 16kHz const results = await vad.processAudio(audioData); // Get speech segments const speechSegments = vad.getSpeechSegments(results); console.log(`Found ${speechSegments.length} speech segments`); speechSegments.forEach((segment, i) => { console.log(`Segment ${i + 1}: ${segment.start}ms - ${segment.end}ms`); }); // Clean up vad.destroy(); ``` -------------------------------- ### Real-time Speech Detector Class Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md A class for real-time speech detection using callbacks for speech start and end events. Initialize with custom callbacks and process audio frames. ```typescript import { RealTimeVAD, Message } from 'avr-vad'; class SpeechDetector { private vad: RealTimeVAD; private onSpeechStart?: (audio: Float32Array) => void; private onSpeechEnd?: (audio: Float32Array) => void; constructor(callbacks: { onSpeechStart?: (audio: Float32Array) => void; onSpeechEnd?: (audio: Float32Array) => void; }) { this.onSpeechStart = callbacks.onSpeechStart; this.onSpeechEnd = callbacks.onSpeechEnd; } async initialize() { this.vad = await RealTimeVAD.new({ positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35, onSpeechStart: this.onSpeechStart, onSpeechEnd: this.onSpeechEnd }); } async processFrame(audioFrame: Float32Array) { const result = await this.vad.processFrame(audioFrame); return result; } destroy() { this.vad?.destroy(); } } // Usage const detector = new SpeechDetector({ onSpeechStart: (audio) => console.log(`Speech started with ${audio.length} samples`), onSpeechEnd: (audio) => console.log(`Speech ended with ${audio.length} samples`) }); await detector.initialize(); ``` -------------------------------- ### Define Speech Segment Interface Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Defines the structure for a speech segment, including start and end times in milliseconds, and speech probability. ```typescript interface SpeechSegment { /** Start time in milliseconds */ start: number; /** End time in milliseconds */ end: number; /** Speech probability for this segment */ probability: number; } ``` -------------------------------- ### VAD Messages Enum Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Defines the possible message types returned by the VAD to indicate speech state changes, such as speech start, end, or silence. ```typescript enum Message { ERROR = 'ERROR', SPEECH_START = 'SPEECH_START', SPEECH_CONTINUE = 'SPEECH_CONTINUE', SPEECH_END = 'SPEECH_END', SILENCE = 'SILENCE' } ``` -------------------------------- ### Run Tests Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Executes the project tests using npm. ```bash npm test ``` -------------------------------- ### Initialize and Use FrameProcessor for VAD Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Demonstrates initializing FrameProcessor with custom model functions and options, processing audio frames, and handling speech detection events. Ensure modelProcess and modelReset functions are correctly implemented. ```typescript import { FrameProcessor, Message } from 'avr-vad'; // Create a model process function (normally provided by Silero model) const modelProcess = async (frame: Float32Array) => { // Returns speech probability return { isSpeech: 0.85, notSpeech: 0.15 }; }; const modelReset = () => { // Reset model state }; // Initialize frame processor with options const frameProcessor = new FrameProcessor(modelProcess, modelReset, { frameSamples: 1536, positiveSpeechThreshold: 0.6, // Speech starts above this negativeSpeechThreshold: 0.4, // Speech ends below this redemptionFrames: 4, // Wait 4 frames before ending speech preSpeechPadFrames: 5, // Include 5 frames before speech start minSpeechFrames: 6, // Minimum frames for valid speech submitUserSpeechOnPause: false // Don't emit on pause }); // Activate processing frameProcessor.resume(); // Process frames and handle events const handleEvent = (event) => { switch (event.msg) { case Message.SpeechStart: console.log('Tentative speech start detected'); break; case Message.SpeechRealStart: console.log('Speech confirmed (minimum frames reached)'); break; case Message.SpeechEnd: console.log(`Speech ended with ${event.audio.length} samples`); break; case Message.VADMisfire: console.log('False positive - segment too short'); break; case Message.FrameProcessed: console.log(`Probability: ${event.probs.isSpeech}`); break; } }; // Process audio frames const frame = new Float32Array(1536); // Your audio frame await frameProcessor.process(frame, handleEvent); // Force end of current segment frameProcessor.endSegment(handleEvent); // Pause processing (optionally submitting current speech) frameProcessor.pause(handleEvent); // Reset all state frameProcessor.reset(); ``` -------------------------------- ### Lint Project Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Runs ESLint for code linting. ```bash npm run lint ``` -------------------------------- ### Real-time VAD Initialization and Usage Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Initialize RealTimeVAD for live audio streams. Configure model, sample rate, thresholds, padding, and event callbacks. Automatically resamples audio to 16kHz. Call processAudio() with Float32Array frames. ```typescript import { RealTimeVAD, Message } from 'avr-vad'; // Initialize with the v5 model (default) and custom callbacks const vad = await RealTimeVAD.new({ model: 'v5', // or 'legacy' for the older model sampleRate: 16000, // Input sample rate (will resample if > 16000) positiveSpeechThreshold: 0.5, // Threshold for speech detection (0-1) negativeSpeechThreshold: 0.35, // Threshold for speech end detection preSpeechPadFrames: 3, // Frames to include before speech redemptionFrames: 24, // Grace period frames before ending speech frameSamples: 512, // Samples per frame (512 for v5, 1536 for legacy) minSpeechFrames: 9, // Minimum frames for valid speech segment // Event callbacks onSpeechStart: () => { console.log('Speech started (tentative)'); }, onSpeechRealStart: () => { console.log('Speech confirmed (min frames reached)'); }, onSpeechEnd: (audio: Float32Array) => { console.log(`Speech ended, captured ${audio.length} samples`); // Process the captured speech audio saveAudioSegment(audio); }, onVADMisfire: () => { console.log('False positive - speech too short'); }, onFrameProcessed: (probs, frame) => { console.log(`Frame processed: speech probability = ${probs.isSpeech.toFixed(3)}`); } }); // Start processing vad.start(); // Feed audio frames from microphone or stream // Audio should be Float32Array with values between -1.0 and 1.0 const audioFrame = getMicrophoneFrame(); // Your audio source await vad.processAudio(audioFrame); // When pausing/stopping vad.pause(); // Flush remaining audio and trigger final speech end if needed await vad.flush(); // Reset state for new audio stream vad.reset(); // Clean up when done await vad.destroy(); ``` -------------------------------- ### Initialize Audio Resampler Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Initializes a Resampler utility to convert audio to 16kHz, which is required for VAD processing. Specify native sample rate, target sample rate, and target frame size. ```typescript import { utils, Resampler } from 'avr-vad'; // Resample audio to 16kHz (required for VAD) const resampler = new Resampler({ nativeSampleRate: 44100, targetSampleRate: 16000, targetFrameSize: 1536 }); const resampledFrame = resampler.process(audioFrame); // Other utilities const frameSize = utils.frameSize; // Get frame size for current sample rate const audioBuffer = utils.concatArrays([frame1, frame2]); // Concatenate audio arrays ``` -------------------------------- ### Initialize Audio Resampler for VAD Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Configures the Resampler utility to convert audio to the format required by the Silero VAD model: 16kHz sample rate and a frame size of 1536 samples. ```typescript import { Resampler } from 'avr-vad'; const resampler = new Resampler({ nativeSampleRate: 44100, // Your audio sample rate targetSampleRate: 16000, // Required by VAD targetFrameSize: 1536 // Required frame size }); ``` -------------------------------- ### Clean Build Directory Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Removes the build directory. ```bash npm run clean ``` -------------------------------- ### Batch Audio Processing with NonRealTimeVAD Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Process complete audio files using NonRealTimeVAD. Initialize with parameters and use the async generator 'run' to iterate over detected speech segments with start/end times and audio data. ```typescript import { NonRealTimeVAD } from 'avr-vad'; import * as fs from 'fs'; // Initialize for batch processing const vad = await NonRealTimeVAD.new({ positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35, frameSamples: 1536, redemptionFrames: 8, preSpeechPadFrames: 1, minSpeechFrames: 3 }); // Load audio file (you need your own WAV decoder) const audioBuffer = fs.readFileSync('audio.wav'); const audioData = decodeWavToFloat32Array(audioBuffer); // Float32Array const sampleRate = 44100; // Original sample rate of your audio // Process and iterate over detected speech segments const speechSegments = []; for await (const segment of vad.run(audioData, sampleRate)) { console.log(`Speech segment: ${segment.start}ms - ${segment.end}ms`); console.log(`Audio samples: ${segment.audio.length}`); speechSegments.push({ start: segment.start, end: segment.end, duration: segment.end - segment.start, audio: segment.audio }); } console.log(`Found ${speechSegments.length} speech segments`); // Clean up await vad.destroy(); // Example output: // Speech segment: 2100ms - 3200ms // Audio samples: 17600 // Found 1 speech segments ``` -------------------------------- ### Audio Utility Functions for WAV Encoding and Conversion Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Utilize helper functions from 'avr-vad/utils' for audio processing. Functions include calculating frames for target duration, encoding audio to WAV, and converting ArrayBuffers to Base64. ```typescript import { utils } from 'avr-vad'; const { encodeWAV, minFramesForTargetMS, arrayBufferToBase64 } = utils; // Calculate minimum frames needed for a target duration const frameSamples = 1536; const targetDurationMs = 500; // 500 milliseconds const minFrames = minFramesForTargetMS(targetDurationMs, frameSamples); console.log(`Need at least ${minFrames} frames for ${targetDurationMs}ms`); // Output: Need at least 6 frames for 500ms // Encode Float32Array audio to WAV format const speechAudio = getSpeechSegment(); // Float32Array at 16kHz const wavBuffer = encodeWAV( speechAudio, 3, // Format: 3 = Float32, 1 = PCM16 16000, // Sample rate 1, // Mono channel 32 // Bit depth ); // Save to file const fs = require('fs'); fs.writeFileSync('speech.wav', Buffer.from(wavBuffer)); // Convert to base64 for transmission const base64Audio = arrayBufferToBase64(wavBuffer); console.log(`Base64 length: ${base64Audio.length}`); // Send to API await fetch('/api/transcribe', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ audio: base64Audio }) }); // Encode as 16-bit PCM for compatibility const pcmWavBuffer = encodeWAV( speechAudio, 1, // PCM format 16000, 1, 16 // 16-bit ); ``` -------------------------------- ### Resampler for Audio Sample Rate Conversion Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Shows how to use the Resampler class to convert audio from a source sample rate to 16kHz for VAD processing. Supports both batch and streaming modes. ```typescript import { Resampler } from 'avr-vad'; // Create resampler for 44.1kHz source audio const resampler = new Resampler({ nativeSampleRate: 44100, // Source sample rate targetSampleRate: 16000, // VAD requires 16kHz targetFrameSize: 1536 // Output frame size (1536 for legacy, 512 for v5) }); // Option 1: Batch process entire audio buffer const audioData = loadAudioFile(); // Float32Array at 44.1kHz const resampledFrames = resampler.process(audioData); console.log(`Generated ${resampledFrames.length} frames`); resampledFrames.forEach((frame, i) => { console.log(`Frame ${i}: ${frame.length} samples`); // Each frame is Float32Array of targetFrameSize samples at 16kHz }); // Option 2: Stream processing for real-time applications const resampler2 = new Resampler({ nativeSampleRate: 48000, targetSampleRate: 16000, targetFrameSize: 512 }); // Process audio chunks as they arrive for await (const frame of resampler2.stream(audioData)) { // Each frame is ready for VAD processing await vad.processFrame(frame); } // Example with microphone input const micResampler = new Resampler({ nativeSampleRate: 48000, // Common microphone rate targetSampleRate: 16000, targetFrameSize: 512 }); // In your audio callback function onMicrophoneData(chunk: Float32Array) { const frames = micResampler.process(chunk); for (const frame of frames) { processWithVAD(frame); } } ``` -------------------------------- ### Batch Process Audio File Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Processes an entire audio file using NonRealTimeVAD to detect speech segments. Requires audio data loaded as Float32Array at 16kHz. Customize model and thresholds. ```typescript import { NonRealTimeVAD, utils } from 'avr-vad'; import * as fs from 'fs'; async function processAudioFile(filePath: string) { // Load audio data (you'll need your own audio loading logic) const audioData = loadWavFile(filePath); // Float32Array at 16kHz const vad = await NonRealTimeVAD.new({ model: 'v5', positiveSpeechThreshold: 0.6, negativeSpeechThreshold: 0.4 }); const results = await vad.processAudio(audioData); const segments = vad.getSpeechSegments(results); console.log(`Processing ${filePath}:`); console.log(`Total audio duration: ${(audioData.length / 16000).toFixed(2)}s`); console.log(`Speech segments found: ${segments.length}`); segments.forEach((segment, i) => { const duration = ((segment.end - segment.start) / 1000).toFixed(2); console.log(` Segment ${i + 1}: ${segment.start}ms - ${segment.end}ms (${duration}s)`); }); vad.destroy(); return segments; } ``` -------------------------------- ### Real-time VAD Options Interface Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Defines the configuration options for the RealTimeVAD, including model selection, speech thresholds, padding, and frame size. ```typescript interface RealTimeVADOptions { /** Model version to use ('v5' | 'legacy') */ model?: 'v5' | 'legacy'; /** Threshold for detecting speech start */ positiveSpeechThreshold?: number; /** Threshold for detecting speech end */ negativeSpeechThreshold?: number; /** Frames to include before speech detection */ preSpeechPadFrames?: number; /** Frames to wait before ending speech */ redemptionFrames?: number; /** Number of samples per frame (usually 1536 for 16kHz) */ frameSamples?: number; /** Minimum frames for valid speech */ minSpeechFrames?: number; } ``` -------------------------------- ### Default Real-time VAD Options Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Specifies the default configuration values used when initializing RealTimeVAD if not explicitly provided. ```typescript // Real-time VAD defaults const defaultRealTimeOptions = { model: 'v5', positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35, preSpeechPadFrames: 1, redemptionFrames: 8, frameSamples: 1536, minSpeechFrames: 3 }; ``` -------------------------------- ### Non-Real-time VAD Options Interface Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Defines the configuration options for the NonRealTimeVAD, focusing on model selection and speech detection thresholds. ```typescript interface NonRealTimeVADOptions { /** Model version to use ('v5' | 'legacy') */ model?: 'v5' | 'legacy'; /** Threshold for detecting speech start */ positiveSpeechThreshold?: number; /** Threshold for detecting speech end */ negativeSpeechThreshold?: number; } ``` -------------------------------- ### Default Non-real-time VAD Options Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Specifies the default configuration values used when initializing NonRealTimeVAD if not explicitly provided. ```typescript // Non-real-time VAD defaults const defaultNonRealTimeOptions = { model: 'v5', positiveSpeechThreshold: 0.5, negativeSpeechThreshold: 0.35 }; ``` -------------------------------- ### Handle VAD Events with Message Enum Source: https://context7.com/agentvoiceresponse/avr-vad/llms.txt Use the Message enum to handle various VAD events. Import `Message` from 'avr-vad'. Events include frame processing, speech start/end, misfires, and audio frames. ```typescript import { Message } from 'avr-vad'; // Available message types const messages = { // Frame was processed, includes probability data FRAME_PROCESSED: Message.FrameProcessed, // Tentative speech start (may be misfire if too short) SPEECH_START: Message.SpeechStart, // Speech confirmed after minSpeechFrames reached SPEECH_REAL_START: Message.SpeechRealStart, // Speech segment ended, includes audio data SPEECH_END: Message.SpeechEnd, // False positive - speech was too short VAD_MISFIRE: Message.VADMisfire, // Raw audio frame received AUDIO_FRAME: Message.AudioFrame, // Speech stopped (user-initiated) SPEECH_STOP: Message.SpeechStop }; // Usage in event handler function handleVADEvent(event) { if (event.msg === Message.SpeechStart) { // Update UI to show "listening..." showListeningIndicator(); } else if (event.msg === Message.SpeechRealStart) { // Confirmed speech - start recording startRecording(); } else if (event.msg === Message.SpeechEnd) { // Process completed speech segment const audioSegment = event.audio; sendToSpeechRecognition(audioSegment); } else if (event.msg === Message.VADMisfire) { // Too short - likely background noise discardCurrentSegment(); } else if (event.msg === Message.FrameProcessed) { // Update real-time visualization updateProbabilityMeter(event.probs.isSpeech); } } ``` -------------------------------- ### VAD Processing Result Interface Source: https://github.com/agentvoiceresponse/avr-vad/blob/main/README.md Defines the structure of the result object returned after processing audio with the VAD, including speech probability and a message indicating the current state. ```typescript interface VADResult { /** Speech probability (0.0 - 1.0) */ probability: number; /** Message indicating speech state */ msg: Message; /** Audio data if speech segment ended */ audio?: Float32Array; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.