pub struct VadSession { /* private fields */ }Expand description
A VAD session.
Implementations§
Source§impl VadSession
impl VadSession
Sourcepub fn set_cancel_token(&mut self, token: &CancelToken)
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.
Sourcepub fn clear_cancel_token(&mut self)
pub fn clear_cancel_token(&mut self)
Remove any installed cancel token.
Sourcepub fn run(&mut self, pcm: &[f32], options: &VadOptions) -> Result<VadResult>
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.
Sourcepub fn stream_feed(&mut self, pcm: &[f32]) -> Result<VadResult>
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.
Sourcepub fn stream_flush(&mut self) -> Result<VadResult>
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.
Sourcepub fn stream_reset(&mut self)
pub fn stream_reset(&mut self)
Drop the stream without scoring; the next feed starts at frame 0.