Struct Vad

Source
pub struct Vad { /* private fields */ }

Implementations§

Source§

impl Vad

Source

pub fn new() -> Self

Creates and initializes a VAD instance.

On success, returns a pointer to the new VAD instance, which should eventually be deleted using fvad_free().

Panics in case of a memory allocation error.

Defaults to 8KHz sample rate and Quality mode.

Source

pub fn new_with_rate(sample_rate: SampleRate) -> Self

Creates and initializes a VAD instance.

On success, returns a pointer to the new VAD instance, which should eventually be deleted using fvad_free().

Panics in case of a memory allocation error.

Defaults to Quality mode.

Valid values for the sample rate are 8000, 16000, 32000 and 48000. The default is 8000. Note that internally all processing will be done 8000 Hz; input data in higher sample rates will just be downsampled first.

Source

pub fn new_with_mode(mode: VadMode) -> Self

Creates and initializes a VAD instance.

On success, returns a pointer to the new VAD instance, which should eventually be deleted using fvad_free().

Panics in case of a memory allocation error.

Defaults to 8000 sample rate.

Source

pub fn new_with_rate_and_mode(sample_rate: SampleRate, mode: VadMode) -> Self

Creates and initializes a VAD instance.

On success, returns a pointer to the new VAD instance, which should eventually be deleted using fvad_free().

Panics in case of a memory allocation error.

Valid values for the sample rate are 8000, 16000, 32000 and 48000. The default is 8000. Note that internally all processing will be done 8000 Hz; input data in higher sample rates will just be downsampled first.

Source

pub fn reset(&mut self)

Reinitializes a VAD instance, clearing all state and resetting mode and sample rate to defaults.

Source

pub fn set_sample_rate(&mut self, sample_rate: SampleRate)

Sets the input sample rate in Hz for a VAD instance.

Valid values are 8000, 16000, 32000 and 48000. The default is 8000. Note that internally all processing will be done 8000 Hz; input data in higher sample rates will just be downsampled first.

Source

pub fn set_mode(&mut self, mode: VadMode)

Changes the VAD operating (“aggressiveness”) mode of a VAD instance.

A more aggressive (higher mode) VAD is more restrictive in reporting speech. Put in other words the probability of being speech when the VAD returns 1 is increased with increasing mode. As a consequence also the missed detection rate goes up.

Valid modes are 0 (“quality”), 1 (“low bitrate”), 2 (“aggressive”), and 3 (“very aggressive”). The default mode is 0.

Source

pub fn is_voice_segment(&mut self, buffer: &[i16]) -> Result<bool, ()>

Calculates a VAD decision for an audio frame.

frame is an array of length signed 16-bit samples. Only frames with a length of 10, 20 or 30 ms are supported, so for example at 8 kHz, length must be either 80, 160 or 240.

Returns : Ok(true) - (active voice), Ok(false) - (non-active Voice), Err(()) - (invalid frame length).

Trait Implementations§

Source§

impl Default for Vad

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Vad

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Vad

§

impl RefUnwindSafe for Vad

§

impl !Send for Vad

§

impl !Sync for Vad

§

impl Unpin for Vad

§

impl UnwindSafe for Vad

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 = 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.