Expand description
Per-frame voice-activity decision from a fusion of three cheap, orthogonal cues:
- Energy above an adaptive noise floor — the primary gate. Activity requires the frame RMS to clear the (caller-supplied) noise floor by a margin; the size of the margin, in dB, sets the confidence.
- Spectral flatness — tonal/harmonic content (low flatness) is structured signal; a flat (white-ish) spectrum is noise-like. This raises confidence for structured frames but never vetoes a clearly above-floor frame, so a genuine noise burst is still reported as active.
- Zero-crossing rate — a coarse spectral-tilt proxy; voiced/percussive content sits in a plausible mid range, extreme values are down-weighted.
EPISTEMIC RULE: the output is a proposal, not ground truth. A frame at or below the noise floor is returned unvoiced with zero confidence — silence is never forced into “speech”. Confidence is fused so that the energy gate dominates and the spectral/temporal cues only modulate a frame that has already cleared the floor.
Zero-heap hot path: spectral flatness is computed through an in-place FFT
over fixed stack scratch buffers (no allocation). Frames whose length is
not a power of two, or longer than MAX_VAD_FFT, skip the spectral cue and
fall back to a neutral tonality — the energy gate still applies.
Constants§
- MAX_
VAD_ FFT - Largest frame length (samples) for which the stack-buffered spectral-flatness cue is computed. Covers the usual 256/512/1024-sample VAD frames; longer frames fall back to the energy+ZCR decision with neutral tonality.
Functions§
- frame_
is_ voiced - Binary voiced/unvoiced proposal for one frame.
- frame_
voicing_ score - Fused voice-activity confidence in
[0, 1]for one frame.