Skip to main content

adk_audio/traits/
vad.rs

1//! Voice Activity Detection trait.
2
3/// A detected speech segment within an audio frame.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct SpeechSegment {
6    /// Start offset in milliseconds.
7    pub start_ms: u32,
8    /// End offset in milliseconds.
9    pub end_ms: u32,
10}
11
12use crate::frame::AudioFrame;
13
14/// Trait for Voice Activity Detection processors.
15///
16/// Used by the voice agent pipeline to gate STT inference
17/// to speech-only segments.
18pub trait VadProcessor: Send + Sync {
19    /// Returns `true` if the frame contains speech.
20    fn is_speech(&self, frame: &AudioFrame) -> bool;
21
22    /// Identify speech segments within the frame.
23    fn segment(&self, frame: &AudioFrame) -> Vec<SpeechSegment>;
24}