Skip to main content

FrameResult

Struct FrameResult 

Source
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

Source

pub const FRAME_SHIFT_SAMPLES: u32 = 160

Frame shift in samples (160 at 16 kHz, i.e. 10 ms).

Source

pub const SAMPLE_RATE_HZ: u32 = 16_000

Sample rate in Hz (always 16_000).

Source

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.

Source

pub const fn frame_index(&self) -> u64

0-based frame index.

Source

pub const fn raw_prob(&self) -> f32

Raw sigmoid output from the model for this frame.

Source

pub const fn smoothed_prob(&self) -> f32

Trailing moving-average of raw_prob over the configured smooth window.

Source

pub const fn is_speech(&self) -> bool

Whether smoothed_prob exceeds the speech threshold.

Source

pub const fn is_speech_start(&self) -> bool

Whether this frame opened a new segment.

Source

pub const fn is_speech_end(&self) -> bool

Whether this frame closed an open segment.

Source

pub const fn speech_start_frame(&self) -> Option<u64>

0-based frame index of the most recent segment opening, if any.

Source

pub const fn speech_end_frame(&self) -> Option<u64>

0-based frame index of the most recent segment closing, if any.

Source

pub fn timestamp(&self) -> Duration

Timestamp at the start of this frame.

Source

pub fn closed_segment(&self) -> Option<SpeechSegment>

If this frame closes a segment, return it; otherwise None.

Trait Implementations§

Source§

impl Clone for FrameResult

Source§

fn clone(&self) -> FrameResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FrameResult

Source§

impl Debug for FrameResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FrameResult

Source§

fn eq(&self, other: &FrameResult) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FrameResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more