pub struct FrameResult { /* private fields */ }Expand description
Per-frame view of the streaming detector’s internal state.
One FrameResult is produced for every 10 ms frame consumed by
crate::Vad::push_samples. The slice from the most recent
non-empty push_samples call is accessible via
crate::Vad::recent_frames.
Frame indices are 0-based; upstream Python uses 1-based indices and
we shift on construction. speech_start_frame and
speech_end_frame are the 0-based frame indices of the most-recent
segment opening and closing seen so far (None until a segment has
actually opened).
Implementations§
Source§impl FrameResult
impl FrameResult
Sourcepub const FRAME_SHIFT_SAMPLES: u32 = 160
pub const FRAME_SHIFT_SAMPLES: u32 = 160
Frame shift in samples (160 at 16 kHz, i.e. 10 ms).
Sourcepub const SAMPLE_RATE_HZ: u32 = 16_000
pub const SAMPLE_RATE_HZ: u32 = 16_000
Sample rate in Hz (always 16_000).
Sourcepub const fn new(
frame_index: u64,
raw_prob: f32,
smoothed_prob: f32,
is_speech: bool,
is_speech_start: bool,
is_speech_end: bool,
speech_start_frame: Option<u64>,
speech_end_frame: Option<u64>,
) -> Self
pub const fn new( frame_index: u64, raw_prob: f32, smoothed_prob: f32, is_speech: bool, is_speech_start: bool, is_speech_end: bool, speech_start_frame: Option<u64>, speech_end_frame: Option<u64>, ) -> Self
Construct a FrameResult. Public so it is easy to assemble in
tests; the Vad engine is the normal producer.
Sourcepub const fn frame_index(&self) -> u64
pub const fn frame_index(&self) -> u64
0-based frame index.
Sourcepub const fn smoothed_prob(&self) -> f32
pub const fn smoothed_prob(&self) -> f32
Trailing moving-average of raw_prob over the configured smooth window.
Sourcepub const fn is_speech_start(&self) -> bool
pub const fn is_speech_start(&self) -> bool
Whether this frame opened a new segment.
Sourcepub const fn is_speech_end(&self) -> bool
pub const fn is_speech_end(&self) -> bool
Whether this frame closed an open segment.
Sourcepub const fn speech_start_frame(&self) -> Option<u64>
pub const fn speech_start_frame(&self) -> Option<u64>
0-based frame index of the most recent segment opening, if any.
Sourcepub const fn speech_end_frame(&self) -> Option<u64>
pub const fn speech_end_frame(&self) -> Option<u64>
0-based frame index of the most recent segment closing, if any.
Sourcepub fn closed_segment(&self) -> Option<SpeechSegment>
pub fn closed_segment(&self) -> Option<SpeechSegment>
If this frame closes a segment, return it; otherwise None.
Trait Implementations§
Source§impl Clone for FrameResult
impl Clone for FrameResult
Source§fn clone(&self) -> FrameResult
fn clone(&self) -> FrameResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more