pub trait AudioTurnDetector: Send + Sync {
// Required methods
fn push_audio(&mut self, frame: &AudioFrame<'_>);
fn predict(&mut self) -> Result<TurnPrediction, TurnError>;
fn reset(&mut self);
}Expand description
Turn detector that operates on raw audio.
Implementations buffer audio internally and run prediction on demand.
Most users should wrap this in TurnController rather than calling
these methods directly. The controller tracks prediction state and provides
reset_if_finished for correct
multi-utterance handling.
§Direct usage (advanced)
If you need full control over reset logic:
- Every audio chunk →
push_audio - VAD fires “speech stopped” →
predict - New turn begins →
reset
Note: calling reset unconditionally on every VAD speech-start will discard
audio context when the user pauses mid-sentence. See TurnController for
the recommended approach.
Required Methods§
Sourcefn push_audio(&mut self, frame: &AudioFrame<'_>)
fn push_audio(&mut self, frame: &AudioFrame<'_>)
Feed audio into the internal buffer.
Call continuously with incoming audio frames (16 kHz mono).
Sourcefn predict(&mut self) -> Result<TurnPrediction, TurnError>
fn predict(&mut self) -> Result<TurnPrediction, TurnError>
Run prediction on buffered audio.
Call when VAD detects end of speech. The buffer is not cleared
after prediction — call reset explicitly
when starting a new turn.
Sourcefn reset(&mut self)
fn reset(&mut self)
Unconditionally clear the internal buffer.
Use when you are certain a new turn is starting (e.g. after the
assistant finishes responding). For VAD speech-start events where
the user may be continuing, prefer
TurnController::reset_if_finished.