Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A transcription session.

Implementations§

Source§

impl Session

Source

pub fn set_cancel_token(&mut self, token: &CancelToken)

Install a CancelToken so an in-flight run/stream can be aborted from another thread. Replaces any previously installed token. The token’s flag is shared, so cancel via any clone of it. (Cancellation only takes effect on models whose family honors the abort callback — Feature::Cancellation.)

Source

pub fn clear_cancel_token(&mut self)

Remove any installed cancel token.

Source

pub fn was_aborted(&self) -> bool

Whether the most recent run/stream was ended by cancellation.

Source

pub fn was_truncated(&self) -> bool

Whether the most recent decode stopped at the generation budget before end-of-stream (the transcript is incomplete).

Source

pub fn run(&mut self, pcm: &[f32], options: &RunOptions) -> Result<Transcript>

Transcribe one buffer of 16 kHz mono float32 PCM in [-1, 1].

On an aborted or truncated decode the partial transcript is preserved on the returned Error::Aborted / Error::OutputTruncated.

Source

pub fn run_batch( &mut self, pcms: &[&[f32]], options: &RunOptions, ) -> Result<Vec<Result<Transcript>>>

Transcribe several buffers in one call (throughput path).

Returns the whole-batch outcome as an outer Result; each utterance’s individual outcome is an inner Result in the returned vector (one per input, in order). A malformed single utterance fails only its own slot.

Source

pub fn limits(&self) -> Result<SessionLimits>

The effective per-session limits.

Source

pub fn model(&self) -> Model

The model this session is bound to.

Source

pub fn stream( &mut self, run: &RunOptions, stream: &StreamOptions, ) -> Result<Stream<'_>>

Begin a streaming run, returning a Stream that borrows this session for its lifetime (so the session can’t be used for an offline run while a stream is active). run supplies task / language / timestamps; stream supplies the commit policy and any stream-slot family extension. Dropping the returned Stream abandons it and returns the session to idle.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Session

Auto Trait Implementations§

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 = !

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.