clawft_plugin/voice/
vad.rs1#[non_exhaustive]
5#[derive(Debug, Clone)]
6pub enum VadEvent {
7 SpeechStart { offset: usize },
9 SpeechEnd { offset: usize },
11 Silence,
13}
14
15pub struct VoiceActivityDetector {
19 threshold: f32,
20 silence_timeout_ms: u32,
21 active: bool,
22}
23
24impl VoiceActivityDetector {
25 pub fn new(threshold: f32, silence_timeout_ms: u32) -> Self {
26 Self {
27 threshold,
28 silence_timeout_ms,
29 active: false,
30 }
31 }
32
33 pub fn process(&mut self, _samples: &[f32]) -> Vec<VadEvent> {
36 vec![VadEvent::Silence]
38 }
39
40 pub fn reset(&mut self) {
42 self.active = false;
43 }
44
45 pub fn threshold(&self) -> f32 {
46 self.threshold
47 }
48
49 pub fn silence_timeout_ms(&self) -> u32 {
50 self.silence_timeout_ms
51 }
52}