pub struct Session { /* private fields */ }Expand description
A transcription session.
Implementations§
Source§impl Session
impl Session
Sourcepub fn set_cancel_token(&mut self, token: &CancelToken)
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.)
Sourcepub fn clear_cancel_token(&mut self)
pub fn clear_cancel_token(&mut self)
Remove any installed cancel token.
Sourcepub fn was_aborted(&self) -> bool
pub fn was_aborted(&self) -> bool
Whether the most recent run/stream was ended by cancellation.
Sourcepub fn was_truncated(&self) -> bool
pub fn was_truncated(&self) -> bool
Whether the most recent decode stopped at the generation budget before end-of-stream (the transcript is incomplete).
Sourcepub fn run(&mut self, pcm: &[f32], options: &RunOptions) -> Result<Transcript>
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.
Sourcepub fn run_batch(
&mut self,
pcms: &[&[f32]],
options: &RunOptions,
) -> Result<Vec<Result<Transcript>>>
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.
Sourcepub fn limits(&self) -> Result<SessionLimits>
pub fn limits(&self) -> Result<SessionLimits>
The effective per-session limits.
Sourcepub fn stream(
&mut self,
run: &RunOptions,
stream: &StreamOptions,
) -> Result<Stream<'_>>
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.