Skip to main content

Crate rightkit_vad

Crate rightkit_vad 

Source
Expand description

§rightkit-vad

Product-neutral voice activity detection. Owns the Silero scorer (loaded from a caller-supplied ONNX file or embedded bytes; nothing is bundled or downloaded), the frame protocol, and the span/chunking policy. Owns no dictation, push-to-talk or command policy: callers decide what a span means.

Layers, each usable alone:

  • FrameScorer: any per-frame speech-probability source (Silero (feature silero) or a test double).
  • SpeechScorer (feature silero): a constructed scorer that reports its Backend, with an optional energy fallback when Silero cannot load.
  • scores_to_spans: Silero get_speech_timestamps-shaped hysteresis (threshold start, neg_threshold end, min_speech, min_silence, pad, merge).
  • chunk_spans: split/merge spans into decode-sized chunks (max_chunk_ms, min_chunk_ms, merge_gap_ms).
  • FrameStream: lossless streaming carry. Capture callbacks of any size in, whole 512-sample frames out; the remainder is retained, never dropped, because Silero is recurrent. A scorer failure yields None (“unknown”), never silence.

Structs§

ChunkConfig
Decode-chunking knobs. Policy-free: a chunk is just “audio worth decoding in one call”.
FrameStream
Lossless streaming adapter: arbitrary-size capture callbacks in, whole frames scored. The trailing partial frame is carried to the next push so neither the waveform nor the recurrent state ever has a gap. If the scorer fails, push returns None (unknown), which callers must not treat as silence; the stream stays failed until FrameStream::reset.
FrameVerdicts
One entry per complete frame consumed by FrameStream::push.
ResolvedSpans
SpanOptions resolved against ambient audio.
RmsCalibration
Speech threshold from measured ambient RMS: threshold = clamp(max(minimum_threshold, max(rms, noise_floor) * multiplier), 0, 1). The defaults are HeardRight’s: 8x RMS, a 0.005 noise floor, and a 0.20 minimum.
ScorerBackend
What scorer construction produced.
Silero
Silero VAD v5 (16 kHz, op15 ONNX: inputs input/state/sr, outputs output/stateN). Each frame is prefixed with the previous frame’s last 64 samples; recurrent state [2,1,128].
SileroOptions
Session and fallback options for Silero and crate::SpeechScorer.
Span
A speech span in source milliseconds.
SpanOptions
Speech thresholds for span detection, optionally calibrated from ambient audio. resolve turns these into a VadConfig.
VadConfig
Hysteresis/padding policy (Silero get_speech_timestamps shape; the CutRight-proven policy, which is a strict superset of ScrapeRight’s).

Enums§

Backend
The scorer that produced a set of speech scores.
Error
ExecutionProvider
Where the Silero session runs. Asking for a provider this OS cannot host is an error; it is never quietly run on the CPU.
SpeechScorer
A constructed speech scorer.
Spinning
How one of the session’s spinning settings (intra-op or inter-op) is configured.
Warmup
What the warm-up frame leaves behind. Loading runs one all-zero frame to prove the model speaks the protocol; that frame changes the recurrent state.

Constants§

FRAME_MS
Frame duration in milliseconds.
FRAME_SAMPLES
Silero v5 16 kHz frame size (32 ms).
SAMPLE_RATE
Required sample rate.

Traits§

FrameScorer
Per-frame speech probability source. Stateful (recurrent) scorers must honour reset.

Functions§

chunk_spans
Merge near spans and split over-long ones. With scores the split lands on the quietest frame in the last quarter of the window instead of mid-word.
detect
Score every frame of samples (final partial frame zero-padded) and turn the scores into spans.
energy_scores
Energy + zero-crossing pseudo-scores (1.0 speech / 0.0 not) for callers that need a model-free fallback; flows through the same hysteresis.
scores_to_spans
Turn per-frame scores into padded, merged spans.

Type Aliases§

Result