Skip to main content

VadSession

Struct VadSession 

Source
pub struct VadSession { /* private fields */ }
Expand description

A VAD session.

Implementations§

Source§

impl VadSession

Source

pub fn set_cancel_token(&mut self, token: &CancelToken)

Install a CancelToken so an in-flight run, feed or flush can be aborted from another thread (the call then returns Error::Aborted). Replaces any previously installed token.

Source

pub fn clear_cancel_token(&mut self)

Remove any installed cancel token.

Source

pub fn run(&mut self, pcm: &[f32], options: &VadOptions) -> Result<VadResult>

Score one clip of 16 kHz mono float32 PCM from a fresh state and segment it. Resets any stream in progress.

Source

pub fn stream_feed(&mut self, pcm: &[f32]) -> Result<VadResult>

Append audio to the stream and return the probabilities of the frames it completed; a partial frame waits for the next call. On CPU the stream’s probabilities equal a run over the same audio. Error::InvalidArgument (e.g. NaN input) leaves the stream intact; an abort or processing error resets it to frame 0.

Source

pub fn stream_flush(&mut self) -> Result<VadResult>

End the stream: score the buffered partial frame, zero padded (one probability, or none), and reset. The next feed starts at frame 0; a processing error also resets the stream.

Source

pub fn stream_reset(&mut self)

Drop the stream without scoring; the next feed starts at frame 0.

Source

pub fn timings(&self) -> Timings

Model load time plus the last call’s stage timings (encode_ms: front end and encoder; decode_ms: the recurrent decoder).

Trait Implementations§

Source§

impl Debug for VadSession

Source§

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

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

impl Drop for VadSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for VadSession

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.