Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vad-rs

Silero VAD v5 inference in Rust, using candle for CPU tensor ops.

Accepts 24kHz PCM audio and emits SpeechStart / SpeechEnd events with configurable thresholds and hysteresis (redemption frames).

Usage

use vad_rs::{SileroVad, VadDetector};

let model_bytes = std::fs::read("silero-vad-v5.safetensors")?;
let vad = SileroVad::from_bytes(&model_bytes)?;
let mut detector = VadDetector::new(vad);

// Optional: tune sensitivity
detector.set_thresholds(0.5, 0.35);      // positive, negative
detector.set_redemption_frames(8);         // frames below threshold before SpeechEnd

// Feed 24kHz audio in any chunk size
let events = detector.feed_audio(&samples_24khz);
for event in events {
    println!("{event:?}"); // SpeechStart or SpeechEnd
}

Model

Download the safetensors weights from HuggingFace: idle-intelligence/silero-vad-v5-safetensors

API

SileroVad

Low-level: processes exactly 512 samples of 16kHz audio per call, returns speech probability [0, 1].

VadDetector

High-level wrapper:

  • Resamples 24kHz → 16kHz (linear interpolation)
  • Windows into 512-sample chunks
  • State machine with configurable thresholds and redemption frames
  • set_thresholds(positive, negative) — speech start/end probability thresholds (defaults: 0.5, 0.35)
  • set_redemption_frames(n) — consecutive below-threshold frames required for SpeechEnd (default: 8, ~256ms)

Tests

Most tests require the model weights (and some a WAV file). They are #[ignore] by default and enabled with the local-tests feature.

Setup:

mkdir -p test-data
# Symlink or copy the model
ln -s /path/to/silero-vad-v5.safetensors test-data/silero-vad-v5.safetensors
# Place a 24kHz 16-bit PCM WAV for E2E tests
cp /path/to/speech.wav test-data/speech-24khz.wav

The model is available at idle-intelligence/silero-vad-v5-safetensors.

# All tests (requires test-data/)
cargo test --features local-tests

# Default tests only (no model needed)
cargo test

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages