Skip to main content

StreamingPipeline

Struct StreamingPipeline 

Source
pub struct StreamingPipeline<V, E> { /* private fields */ }
Expand description

Stateful streaming diarization pipeline.

Generic over a VoiceActivityDetector V and an Embedder E. Speaker assignment uses an AOSC-style ArrivalOrderSpeakerCache (bounded, arrival-order IDs, provisional→stable labels, prefer-current hysteresis).

Implementations§

Source§

impl<V, E> StreamingPipeline<V, E>

Source

pub fn new( vad: V, extractor: E, config: DiarizationConfig, vad_config: VadConfig, ) -> Result<Self, StreamingError>

Create a new streaming pipeline with explicit diarization + VAD config.

Uses balanced-equivalent cache defaults derived from config.cluster (max_speakers as cache cap, threshold as match threshold) and the balanced stability knobs (min_hits_to_stable = 3, prefer-current margin 0.08). Prefer Self::with_latency_preset for named latency modes.

§Errors

Returns VadError::InvalidChunkSize if the VAD frame_size is zero and StreamingError::InvalidParams if the config’s window geometry is not positive and ordered (0 < hop_secs <= window_secs).

Source

pub fn with_latency_preset( vad: V, extractor: E, preset: LatencyPreset, vad_config: VadConfig, ) -> Result<Self, StreamingError>

Construct a pipeline from a named LatencyPreset.

Applies the preset’s window geometry onto a default DiarizationConfig and installs the matching cache / stability parameters.

Source

pub fn with_params( vad: V, extractor: E, config: DiarizationConfig, vad_config: VadConfig, params: StreamingParams, ) -> Result<Self, StreamingError>

Construct with full control over diarization config and streaming params.

params.speaker_cache_cap == 0 is clamped to 1, matching the max_speakers.max(1) policy of Self::new.

§Errors

Returns VadError::InvalidChunkSize if the VAD frame_size is zero and StreamingError::InvalidParams if the window geometry is not positive and ordered (0 < hop_secs <= window_secs, yielding at least one sample each at the configured sample rate).

Source

pub fn params(&self) -> StreamingParams

Active streaming parameters (window, cache cap, stability knobs).

Source

pub fn latency_preset(&self) -> Option<LatencyPreset>

Named preset if the pipeline was built via Self::with_latency_preset.

Source

pub fn speaker_cache_cap(&self) -> usize

Hard cap on the speaker cache (params.speaker_cache_cap).

Source

pub fn cache_len(&self) -> usize

Current number of cache entries (always <= speaker_cache_cap()).

Source

pub fn feed( &mut self, samples: &[f32], ) -> Result<Vec<SpeakerTurn>, StreamingError>

Feed a chunk of audio samples and return any newly finalized speaker turns.

The pipeline internally buffers samples until a full VAD frame is available, then runs the frame through VAD, speech detection, and — during active speech — extracts embeddings and assigns speakers incrementally.

Callers should feed chunks as they arrive from the audio source (e.g. microphone). There is no minimum chunk size; sub-frame chunks are buffered transparently.

Returned turns may have stable: false (provisional); see module docs.

§VAD frame contract

The detector’s native frame size must equal VadConfig::frame_size, so each buffered frame yields exactly one probability (see the trait’s frame contract). A mismatch is rejected with StreamingError::VadFrameMismatch on the first frame instead of silently shifting every derived timestamp.

Source

pub fn flush(&mut self) -> Result<Vec<SpeakerTurn>, StreamingError>

Flush any pending audio and return final speaker turns.

This finalizes an in-flight speech region (if any), extracts the last embedding window, and clears all internal buffers. After flush the pipeline is ready to process a new stream (or the same stream after a gap) via subsequent feed calls.

Source

pub fn num_speakers(&self) -> usize

Return the number of distinct speakers observed so far.

Source

pub fn turns(&self) -> &[SpeakerTurn]

Return all turns emitted so far (including those from prior feed calls).

History is cumulative across feed/flush; flush does not reset it. Construct a new pipeline for a fresh history.

Auto Trait Implementations§

§

impl<V, E> Freeze for StreamingPipeline<V, E>
where V: Freeze, E: Freeze,

§

impl<V, E> RefUnwindSafe for StreamingPipeline<V, E>

§

impl<V, E> Send for StreamingPipeline<V, E>
where V: Send, E: Send,

§

impl<V, E> Sync for StreamingPipeline<V, E>
where V: Sync, E: Sync,

§

impl<V, E> Unpin for StreamingPipeline<V, E>
where V: Unpin, E: Unpin,

§

impl<V, E> UnsafeUnpin for StreamingPipeline<V, E>
where V: UnsafeUnpin, E: UnsafeUnpin,

§

impl<V, E> UnwindSafe for StreamingPipeline<V, E>
where V: UnwindSafe, E: UnwindSafe,

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

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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