pub struct Committer { /* private fields */ }Expand description
LocalAgreement-2 token committer.
Compares successive window decode outputs and commits the longest stable prefix; everything past that prefix is tentative until the next round confirms it.
Implementations§
Source§impl Committer
impl Committer
pub fn new() -> Self
Sourcepub fn ingest(
&mut self,
candidate: Vec<TokenEmit>,
) -> (CommitDelta, CommitDelta)
pub fn ingest( &mut self, candidate: Vec<TokenEmit>, ) -> (CommitDelta, CommitDelta)
Ingest a new full-window decode result.
Returns (committed_delta, tentative_delta).
Sourcepub fn finalize_utterance(&mut self) -> CommitDelta
pub fn finalize_utterance(&mut self) -> CommitDelta
Force-commit everything tentative. Called by the endpointer on EOU.
After this call, committed_tokens / committed_text still reflect the just-
finalised utterance (so the caller can build a <|prevtext|> prompt from it).
The next ingest will auto-reset the committer for the new utterance. Repeated
finalize_utterance calls without an intervening ingest are a no-op.
pub fn committed_tokens(&self) -> &[TokenEmit]
pub fn committed_text(&self) -> &str
Sourcepub fn last_candidate(&self) -> &[TokenEmit]
pub fn last_candidate(&self) -> &[TokenEmit]
The most recent candidate (the argument to the most recent ingest). Empty
after finalize_utterance (until the next ingest) and after on_trim.
Sourcepub fn last_lcp_end_in_candidate(&self) -> usize
pub fn last_lcp_end_in_candidate(&self) -> usize
Exclusive end index of the most recent LCP within last_candidate(). The streaming
caller uses this with last_candidate() to find the latest timestamp inside the
committed prefix when picking a trim boundary on a cap-hit window.
Sourcepub fn on_trim(&mut self) -> CommitDelta
pub fn on_trim(&mut self) -> CommitDelta
Called after Chunker::trim_oldest succeeds. Force-commits the current tentative
tail (the content past the LCP boundary in the most recent decode) and clears
last_candidate so the next ingest establishes a fresh baseline. Returns the
force-committed text so the caller can mirror it to its output sink.
Rationale: without force-commit, the tentative tail is lost after the trim — the
next stride decodes overlapping audio in a different buffer context, the non-causal
encoder produces different tokens, and LCP doesn’t reconfirm. Empirically this loses
roughly 1.5 s of content per cap-hit. Force-committing trusts the cap-hit window’s
tail; duplication risk is mitigated by clearing last_candidate (post-trim strides
can’t LCP against the pre-trim tail).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Committer
impl RefUnwindSafe for Committer
impl Send for Committer
impl Sync for Committer
impl Unpin for Committer
impl UnsafeUnpin for Committer
impl UnwindSafe for Committer
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<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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