pub struct PartialSession { /* private fields */ }Expand description
Host-driven partial STT session state.
Typical loop:
pushmic chunks- if
should_decode_partial, host runs STT onpartial_window_samples() - call
on_decode_resultwith the transcript text - on release,
finalizewith a definitive full-window decode
Implementations§
Source§impl PartialSession
impl PartialSession
pub fn new(config: PartialSessionConfig) -> Self
pub fn config(&self) -> &PartialSessionConfig
pub fn buffer(&self) -> &PcmBuffer
pub fn buffer_mut(&mut self) -> &mut PcmBuffer
pub fn stable_text(&self) -> &str
pub fn is_closed(&self) -> bool
Sourcepub fn push(&mut self, chunk: &[f32]) -> Result<()>
pub fn push(&mut self, chunk: &[f32]) -> Result<()>
Push mono 16 kHz samples into the ring buffer.
Sourcepub fn should_decode_partial(&self) -> bool
pub fn should_decode_partial(&self) -> bool
Whether the host should start a partial decode now.
Sourcepub fn partial_window_samples(&self) -> ContiguousOwned
pub fn partial_window_samples(&self) -> ContiguousOwned
Contiguous PCM for the current partial window (host passes to STT).
Sourcepub fn begin_partial(&mut self) -> Option<CancelFlag>
pub fn begin_partial(&mut self) -> Option<CancelFlag>
Begin a partial: marks the clock, increments inflight, returns cancel token.
Supersedes any previous inflight cancel token (cooperative cancel).
Sourcepub fn on_decode_result(
&mut self,
raw_text: &str,
latency_ms: Option<u64>,
) -> PartialUpdate
pub fn on_decode_result( &mut self, raw_text: &str, latency_ms: Option<u64>, ) -> PartialUpdate
Host delivers a partial decode result (or error → call Self::end_partial).
Sourcepub fn end_partial(&mut self)
pub fn end_partial(&mut self)
Mark a partial as finished without a text update (cancel/error).
Sourcepub fn finalize(
&mut self,
final_text: &str,
latency_ms: Option<u64>,
) -> PartialUpdate
pub fn finalize( &mut self, final_text: &str, latency_ms: Option<u64>, ) -> PartialUpdate
Final decode path: host supplies definitive transcript for the full buffer.
Sourcepub fn cancel(&mut self) -> PartialUpdate
pub fn cancel(&mut self) -> PartialUpdate
Cancel the session and any in-flight partial.
Auto Trait Implementations§
impl Freeze for PartialSession
impl RefUnwindSafe for PartialSession
impl Send for PartialSession
impl Sync for PartialSession
impl Unpin for PartialSession
impl UnsafeUnpin for PartialSession
impl UnwindSafe for PartialSession
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
Mutably borrows from an owned value. Read more
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>
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 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>
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