Skip to main content

StreamingSession

Trait StreamingSession 

Source
pub trait StreamingSession {
    // Required methods
    fn transcribe_chunk<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        samples: &'life1 [f32],
    ) -> Pin<Box<dyn Future<Output = Result<StreamingResult, AsrError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn finalize_stream<'async_trait>(
        self: Box<Self>,
    ) -> Pin<Box<dyn Future<Output = Result<TranscriptionResult, AsrError>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

A single streaming session — typed via dyn-dispatch to avoid leaking engine-specific state types.

Send bound. #[async_trait] is used here without ?Send, which forces the futures returned by transcribe_chunk and finalize_stream to be Future + Send. Implementors therefore must keep any decoder state held inside the session itself Send too: share engine handles via Arc rather than Rc, push any genuinely thread-local decoder state behind a Send wrapper, and avoid !Send scratch buffers. Callers should still drive a given session from a single thread at a time; the engine itself remains Send + Sync, so multiple sessions can run concurrently across threads.

Relaxing this bound (moving to #[async_trait(?Send)]) is tracked for the streaming engine adoption in issues #50 and #51.

Required Methods§

Source

fn transcribe_chunk<'life0, 'life1, 'async_trait>( &'life0 mut self, samples: &'life1 [f32], ) -> Pin<Box<dyn Future<Output = Result<StreamingResult, AsrError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Feed an audio chunk and get the partial transcript back.

Source

fn finalize_stream<'async_trait>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<TranscriptionResult, AsrError>> + Send + 'async_trait>>
where Self: 'async_trait,

Mark end-of-stream. Returns the final transcript.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§