Skip to main content
Initialize a VAD context for voice activity detection using the Silero VAD model.

Signature

function initWhisperVad(
  options: VadContextOptions
): Promise<WhisperVadContext>

Parameters

options
VadContextOptions
required
Configuration options for the VAD context

Returns

WhisperVadContext
Promise<WhisperVadContext>
A promise that resolves to a WhisperVadContext instance.

Example

import { initWhisperVad } from 'whisper.rn'

// Initialize with a local file
const vadContext = await initWhisperVad({
  filePath: '/path/to/silero_vad.bin',
})

console.log('GPU enabled:', vadContext.gpu)

// Initialize with a bundled asset
const vadContext = await initWhisperVad({
  filePath: require('./assets/silero_vad.bin'),
})

// Initialize with custom settings
const vadContext = await initWhisperVad({
  filePath: '/path/to/silero_vad.bin',
  useGpu: true,
  nThreads: 4,
})

// Use the context for speech detection
const segments = await vadContext.detectSpeech('/path/to/audio.wav')

// Release the context when done
await vadContext.release()

Notes

  • The VAD model file (Silero VAD) is separate from the Whisper model
  • Download the Silero VAD model from the whisper.cpp repository or use a pre-converted .bin file
  • GPU acceleration is currently only available on iOS devices with Metal support
  • Always call context.release() when finished to free memory
  • Use releaseAllWhisperVad() to release all VAD contexts at once

Build docs developers (and LLMs) love