pub struct IdleDetector { /* private fields */ }Expand description
Streaming idle detector over 16 kHz mono samples.
Feed samples via IdleDetector::push; it buffers partial windows
internally and only classifies a window once it is fully filled.
IdleDetector::is_idle returns true once enough consecutive silent
windows have accumulated. The detector also remembers whether any
voiced window has ever been seen — the orchestrator uses that flag to
fail loudly on all-silence recordings (muted mic, etc.) rather than
emit a near-empty WAV that downstream Whisper would crash on.
Implementations§
Source§impl IdleDetector
impl IdleDetector
Sourcepub fn new(idle_after_secs: u32) -> Self
pub fn new(idle_after_secs: u32) -> Self
Builds a detector that fires after idle_after_secs seconds of
uninterrupted silence on the 16 kHz stream.
Sourcepub fn idle_after_secs(&self) -> u32
pub fn idle_after_secs(&self) -> u32
Returns the configured idle-after threshold in seconds.
Sourcepub fn push(&mut self, samples: &[f32]) -> Vec<WindowClass>
pub fn push(&mut self, samples: &[f32]) -> Vec<WindowClass>
Feeds new samples; processes whatever windows are complete and updates internal state. Returns the classifications of windows completed by this call (oldest first) so callers can log or instrument them.
Sourcepub fn is_idle(&self) -> bool
pub fn is_idle(&self) -> bool
Returns true once idle_after_secs consecutive silent windows have
arrived. (At 100 ms per window, that’s 10 * idle_after_secs
windows.) Always false before idle_after_secs == 0 — a zero
threshold disables auto-stop.
Sourcepub fn has_any_voice(&self) -> bool
pub fn has_any_voice(&self) -> bool
Returns true if at least one voiced window has been observed since construction.
Sourcepub fn trailing_silence_samples(&self) -> usize
pub fn trailing_silence_samples(&self) -> usize
Number of samples to drop from the tail of the stream when the
detector has fired — exactly the silent window streak that caused
is_idle to flip true.
Auto Trait Implementations§
impl Freeze for IdleDetector
impl RefUnwindSafe for IdleDetector
impl Send for IdleDetector
impl Sync for IdleDetector
impl Unpin for IdleDetector
impl UnsafeUnpin for IdleDetector
impl UnwindSafe for IdleDetector
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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