Skip to main content

segment_voiced

Function segment_voiced 

Source
pub fn segment_voiced(
    signal: &[f32],
    frame_len: usize,
    hop: usize,
    sample_rate: u32,
    out_segments: &mut [(u32, u32)],
) -> Result<usize, AudioError>
Expand description

Detect voiced segments in signal, writing [start_frame, end_frame) index pairs into out_segments.

  • signal: mono samples in [-1, 1] (or any linear scale).
  • frame_len: analysis window length in samples (power-of-two enables the spectral-flatness cue; see crate::features::vad::frame_voicing_score).
  • hop: advance between frame starts in samples.
  • sample_rate: used only to convert the hysteresis durations to frames.
  • out_segments: caller-owned output; each entry is (start_frame, end_frame) with end exclusive, in frame-index units.

Returns the number of segments written.

ยงErrors

Zero-heap: a single streaming pass over signal; the only working state is a fixed stack ring for the adaptive noise floor.