PhasedStream

Struct PhasedStream 

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

A wrapper around multiple phase-shifted OnlineStream states. The use case is latency reduction at the cost of additional compute load.

For example, a transducer with a chunk size of 320ms has worst-case transcription latency of 320ms; it must be fed with 320ms chunks of audio before producing any results. If an utterance lies at the beginning of a chunk, you must wait until the rest arrives before it can be transcribed.

In a PhasedStream with n_phase == 2, the worst-case latency is reduced to 160ms, though compute utilization is approximately doubled.

This does not mean latency due to compute is doubled; if used correctly, that remains constant. Let Q be the amount of time it takes to transcribe a 320ms chunk: we can feed the transducer with 160ms chunks and expect processing to take Q as well. Instead of paying Q every 320ms we now pay it every 160ms.

Likewise, with n_phase == 3, we could feed 106.7ms chunks and expect to pay Q every 106.7ms. More generally, the computational cost of transcribing a chunk remains constant while the chunk count in a given time window scales linearly with the number of phases.

For most zipformer transducers, RTF is favorable (Q is low) and the extra load can be an acceptable trade off for the observed latency improvement.

Created by Model::phased_stream.

Implementations§

Source§

impl PhasedStream

Source

pub fn accept_waveform(&mut self, sample_rate: usize, samples: &[f32])

Accept ((-1, 1)) normalized) input audio samples and buffer the computed feature frames.

Source

pub fn decode(&mut self)

Decode all available feature frames.

Source

pub fn result(&mut self) -> Result<(usize, String)>

Returns recognition state since the last call to PhasedStream::reset.

Source

pub fn reset(&mut self)

Clear any extant neural network and decoder states.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T