pub struct ArrivalOrderSpeakerCache { /* private fields */ }Expand description
Bounded arrival-order speaker cache for online diarization.
§Overflow / merge semantics
When len() == cap and an embedding does not match any entry above
match_threshold, it is force-merged into the closest entry (no new
speaker is created). This mirrors AWS Transcribe’s documented overflow
behaviour and keeps per-chunk work O(cap).
Eviction (dropping the lowest keep-score entry) is available via
Self::evict_weakest for long streams that need to free a slot for a
clearly new speaker; the default assign path uses force-merge only so
arrival-order IDs never renumber mid-stream.
Implementations§
Source§impl ArrivalOrderSpeakerCache
impl ArrivalOrderSpeakerCache
Sourcepub fn new(
cap: usize,
match_threshold: f32,
min_hits_to_stable: usize,
prefer_current_margin: f32,
) -> Self
pub fn new( cap: usize, match_threshold: f32, min_hits_to_stable: usize, prefer_current_margin: f32, ) -> Self
Create an empty cache.
cap is clamped to at least 1 — a zero-capacity cache could never hold
a speaker, so it is treated as a request for the smallest usable cache
(same policy as the min_hits_to_stable clamp below).
Sourcepub fn speaker_ids(&self) -> Vec<SpeakerId>
pub fn speaker_ids(&self) -> Vec<SpeakerId>
Arrival-order speaker IDs currently resident (sorted by id).
Sourcepub fn assign(&mut self, embedding: &[f32]) -> AssignResult
pub fn assign(&mut self, embedding: &[f32]) -> AssignResult
Assign an embedding to a speaker via cache match / create / overflow merge.
Sourcepub fn evict_weakest(&mut self) -> Option<SpeakerId>
pub fn evict_weakest(&mut self) -> Option<SpeakerId>
Drop the lowest keep-score entry if the cache is at capacity. Returns the evicted speaker id, if any.
Auto Trait Implementations§
impl Freeze for ArrivalOrderSpeakerCache
impl RefUnwindSafe for ArrivalOrderSpeakerCache
impl Send for ArrivalOrderSpeakerCache
impl Sync for ArrivalOrderSpeakerCache
impl Unpin for ArrivalOrderSpeakerCache
impl UnsafeUnpin for ArrivalOrderSpeakerCache
impl UnwindSafe for ArrivalOrderSpeakerCache
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