coqui_stt

Struct Stream

Source
pub struct Stream<'a> { /* private fields */ }
Expand description

Streaming inference state.

Implementations§

Source§

impl<'a> Stream<'a>

Source

pub fn from_model(model: &'a mut Model) -> Result<Stream<'a>>

Create a new Stream from a Model.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub unsafe fn into_state(self) -> *mut StreamingState

Get the inner pointer to the StreamingState of this Stream.

§Safety

Once this is called, the memory management of the Stream is no longer handled for you.

The Model object this stream points to must not be disposed of until this Stream is disposed of.

Once you are done with the pointer, to dispose of the state properly, you must not forget to either (NOT BOTH):

Source

pub unsafe fn from_ptr( model: &'a mut Model, state: *mut StreamingState, ) -> Stream<'a>

Recreate a Stream with a pointer to a StreamingState and a pointer to the model the StreamingState references.

§Safety
  • The state must point to a valid StreamingState.
  • The model must point to the exact same Model the original state was created with.
Source

pub fn model(&self) -> &Model

Return a reference to the Model this Stream references.

Source

pub fn model_mut(&mut self) -> &mut Model

Return a mutable reference to the Model this wraps.

Source

pub fn feed_audio(&mut self, buffer: &[i16])

Feed audio samples to an ongoing streaming inference.

Source

pub fn intermediate_decode(&mut self) -> Result<String>

Compute the intermediate decoding of an ongoing streaming inference.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub fn intermediate_decode_with_metadata( &mut self, num_results: u32, ) -> Result<Metadata>

Compute the intermediate decoding of an ongoing streaming inference, return results including metadata.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub fn intermediate_decode_with_buffer_flush(&mut self) -> Result<String>

EXPERIMENTAL: Compute the intermediate decoding of an ongoing streaming inference, flushing buffers first.

This ensures that all audio that has been streamed so far is included in the result, but is more expensive than intermediate_decode because buffers are processed through the acoustic model.

Calling this function too often will also degrade transcription accuracy due to trashing of the LSTM hidden state vectors.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub fn intermediate_decode_with_metadata_and_buffer_flush( &mut self, num_results: u32, ) -> Result<Metadata>

EXPERIMENTAL: Compute the intermediate decoding of an ongoing streaming inference, flushing buffers first.

This ensures that all audio that has been streamed so far is included in the result, but is more expensive than intermediate_decode_with_metadata because buffers are processed through the acoustic model.

Calling this function too often will also degrade transcription accuracy due to trashing of the LSTM hidden state vectors.

Returns results including metadata.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub fn finish_stream(self) -> Result<String>

Compute the final decoding of an ongoing streaming inference and return the result. Signals the end of an ongoing streaming inference.

Destroys this stream object.

§Errors

Passes through any errors from the C library. See enum Error.

Source

pub fn finish_stream_with_metadata(self, num_results: u32) -> Result<Metadata>

Compute the final decoding of an ongoing streaming inference and return results including metadata. Signals the end of an ongoing streaming inference.

Destroys this stream object.

num_results is the maximum number of possible transcriptions to return. Note that it is not guaranteed this many will be returned at minimum, but there will never be more than this number at maximum.

§Errors

Passes through any errors from the C library. See enum Error.

Trait Implementations§

Source§

impl Drop for Stream<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Stream<'_>

Source§

impl Sync for Stream<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Stream<'a>

§

impl<'a> RefUnwindSafe for Stream<'a>

§

impl<'a> Unpin for Stream<'a>

§

impl<'a> !UnwindSafe for Stream<'a>

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.