Skip to main content

WhisperStreamPcm

Struct WhisperStreamPcm 

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

Streaming PCM transcriber — direct port of stream-pcm.cpp main loop.

Two modes:

  • Fixed-step (use_vad = false): process step_ms chunks with overlap.
  • VAD-driven (use_vad = true): accumulate speech, transcribe on silence.

Implementations§

Source§

impl WhisperStreamPcm

Source

pub fn new( ctx: &WhisperContext, params: FullParams, config: WhisperStreamPcmConfig, reader: PcmReader, ) -> Result<Self>

Create a new WhisperStreamPcm processor (simple VAD or no VAD).

Source

pub fn with_vad( ctx: &WhisperContext, params: FullParams, config: WhisperStreamPcmConfig, reader: PcmReader, vad: WhisperVadProcessor, ) -> Result<Self>

Create a new WhisperStreamPcm processor with Silero VAD.

Source

pub fn is_eof(&self) -> bool

Returns true when the underlying reader has hit EOF and all samples are drained.

Source

pub fn process_step(&mut self) -> Result<Option<Vec<Segment>>>

Run one iteration of the main loop.

Returns Ok(Some(segments)) if transcription occurred, Ok(None) if waiting for more audio or sleeping, Err on fatal error.

Returns Ok(None) with no more audio when EOF + drained.

Source

pub fn run<F>(&mut self, callback: F) -> Result<()>
where F: FnMut(&[Segment], i64, i64),

Run until EOF or error. Calls callback for each transcription.

Source

pub fn total_samples(&self) -> i64

Get the total number of processed samples.

Source

pub fn n_iter(&self) -> i32

Get the iteration count.

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

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.