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>where
V: VoiceActivityDetector,
E: Embedder,
impl<V, E> StreamingPipeline<V, E>where
V: VoiceActivityDetector,
E: Embedder,
Sourcepub fn new(
vad: V,
extractor: E,
config: DiarizationConfig,
vad_config: VadConfig,
) -> Result<Self, StreamingError>
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).
Sourcepub fn with_latency_preset(
vad: V,
extractor: E,
preset: LatencyPreset,
vad_config: VadConfig,
) -> Result<Self, StreamingError>
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.
Sourcepub fn with_params(
vad: V,
extractor: E,
config: DiarizationConfig,
vad_config: VadConfig,
params: StreamingParams,
) -> Result<Self, StreamingError>
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).
Sourcepub fn params(&self) -> StreamingParams
pub fn params(&self) -> StreamingParams
Active streaming parameters (window, cache cap, stability knobs).
Sourcepub fn latency_preset(&self) -> Option<LatencyPreset>
pub fn latency_preset(&self) -> Option<LatencyPreset>
Named preset if the pipeline was built via Self::with_latency_preset.
Sourcepub fn speaker_cache_cap(&self) -> usize
pub fn speaker_cache_cap(&self) -> usize
Hard cap on the speaker cache (params.speaker_cache_cap).
Sourcepub fn cache_len(&self) -> usize
pub fn cache_len(&self) -> usize
Current number of cache entries (always <= speaker_cache_cap()).
Sourcepub fn feed(
&mut self,
samples: &[f32],
) -> Result<Vec<SpeakerTurn>, StreamingError>
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.
Sourcepub fn flush(&mut self) -> Result<Vec<SpeakerTurn>, StreamingError>
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.
Sourcepub fn num_speakers(&self) -> usize
pub fn num_speakers(&self) -> usize
Return the number of distinct speakers observed so far.
Sourcepub fn turns(&self) -> &[SpeakerTurn]
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>
impl<V, E> RefUnwindSafe for StreamingPipeline<V, E>where
V: RefUnwindSafe,
E: RefUnwindSafe,
impl<V, E> Send for StreamingPipeline<V, E>
impl<V, E> Sync for StreamingPipeline<V, E>
impl<V, E> Unpin for StreamingPipeline<V, E>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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