pub struct Stream<'a> { /* private fields */ }
Expand description
Streaming inference state.
Implementations§
Source§impl<'a> Stream<'a>
impl<'a> Stream<'a>
Sourcepub fn from_model(model: &'a mut Model) -> Result<Stream<'a>>
pub fn from_model(model: &'a mut Model) -> Result<Stream<'a>>
Sourcepub unsafe fn into_state(self) -> *mut StreamingState
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):
- call
STT_FreeStream
, - recreate this object with
from_ptr
Sourcepub unsafe fn from_ptr(
model: &'a mut Model,
state: *mut StreamingState,
) -> Stream<'a>
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 validStreamingState
. - The
model
must point to the exact sameModel
the originalstate
was created with.
Sourcepub fn feed_audio(&mut self, buffer: &[i16])
pub fn feed_audio(&mut self, buffer: &[i16])
Feed audio samples to an ongoing streaming inference.
Sourcepub fn intermediate_decode(&mut self) -> Result<String>
pub fn intermediate_decode(&mut self) -> Result<String>
Sourcepub fn intermediate_decode_with_metadata(
&mut self,
num_results: u32,
) -> Result<Metadata>
pub fn intermediate_decode_with_metadata( &mut self, num_results: u32, ) -> Result<Metadata>
Sourcepub fn intermediate_decode_with_buffer_flush(&mut self) -> Result<String>
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
.
Sourcepub fn intermediate_decode_with_metadata_and_buffer_flush(
&mut self,
num_results: u32,
) -> Result<Metadata>
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
.
Sourcepub fn finish_stream(self) -> Result<String>
pub fn finish_stream(self) -> Result<String>
Sourcepub fn finish_stream_with_metadata(self, num_results: u32) -> Result<Metadata>
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
.