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(featuresilero) or a test double).SpeechScorer(featuresilero): a constructed scorer that reports itsBackend, with an optional energy fallback when Silero cannot load.scores_to_spans: Sileroget_speech_timestamps-shaped hysteresis (thresholdstart,neg_thresholdend,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 yieldsNone(“unknown”), never silence.
Structs§
- Chunk
Config - Decode-chunking knobs. Policy-free: a chunk is just “audio worth decoding in one call”.
- Frame
Stream - 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,
pushreturnsNone(unknown), which callers must not treat as silence; the stream stays failed untilFrameStream::reset. - Frame
Verdicts - One entry per complete frame consumed by
FrameStream::push. - Resolved
Spans SpanOptionsresolved 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. - Scorer
Backend - What scorer construction produced.
- Silero
- Silero VAD v5 (16 kHz, op15 ONNX: inputs
input/state/sr, outputsoutput/stateN). Each frame is prefixed with the previous frame’s last 64 samples; recurrent state[2,1,128]. - Silero
Options - Session and fallback options for
Sileroandcrate::SpeechScorer. - Span
- A speech span in source milliseconds.
- Span
Options - Speech thresholds for span detection, optionally calibrated from ambient
audio.
resolveturns these into aVadConfig. - VadConfig
- Hysteresis/padding policy (Silero
get_speech_timestampsshape; the CutRight-proven policy, which is a strict superset of ScrapeRight’s).
Enums§
- Backend
- The scorer that produced a set of speech scores.
- Error
- Execution
Provider - Where the Silero session runs. Asking for a provider this OS cannot host is an error; it is never quietly run on the CPU.
- Speech
Scorer - 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§
- Frame
Scorer - Per-frame speech probability source. Stateful (recurrent) scorers must
honour
reset.
Functions§
- chunk_
spans - Merge near spans and split over-long ones. With
scoresthe 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.