Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    type Stream<'a>: BackendStream + 'a
       where Self: 'a;

    // Required methods
    fn transcribe_full(
        &self,
        opts: &Opts,
        encoder: &mut dyn SegmentEncoder,
        samples: &[f32],
    ) -> Result<()>;
    fn create_stream<'a>(
        &'a self,
        opts: &'a Opts,
        encoder: &'a mut dyn SegmentEncoder,
    ) -> Result<Self::Stream<'a>>;
}
Expand description

Pluggable ASR backend used by crate::Scribble.

A backend is responsible for turning mono f32 samples at Scribble’s target sample rate into Segments written via a SegmentEncoder.

Backends may choose to implement streaming/incremental emission by returning a stream object that implements BackendStream.

Required Associated Types§

Source

type Stream<'a>: BackendStream + 'a where Self: 'a

Streaming transcription state for this backend.

The lifetime typically ties together:

  • the backend borrow (&'a self)
  • the options borrow (&'a Opts)
  • the encoder borrow (&'a mut dyn SegmentEncoder)

Required Methods§

Source

fn transcribe_full( &self, opts: &Opts, encoder: &mut dyn SegmentEncoder, samples: &[f32], ) -> Result<()>

Run a non-streaming transcription pass over a contiguous sample buffer.

Backends should not call encoder.close(); the caller is responsible for encoder lifecycle.

Source

fn create_stream<'a>( &'a self, opts: &'a Opts, encoder: &'a mut dyn SegmentEncoder, ) -> Result<Self::Stream<'a>>

Create a streaming transcriber that accepts samples incrementally.

Backends should not call encoder.close(); the caller is responsible for encoder lifecycle.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Backend for WhisperBackend

Source§

type Stream<'a> = WhisperStream<'a> where Self: 'a