1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Wake word detection for the voice assistant pipeline.
//!
//! A wake word is a short phrase (e.g. "hey assistant", "ok computer") that
//! activates the voice assistant from idle. Two backends are supported:
//!
//! - [`EnergyTriggerDetector`] — zero-dependency RMS-burst fallback. Fires
//! on any sustained audio energy above a threshold. Feature: `wake-word`.
//! - [`DtwWakeWordDetector`] — in-house DTW (Dynamic Time Warping) over
//! MFCC features. Pure-Rust DSP, no ML framework, no third-party
//! wake-word library. Speaker-dependent — callers enroll 3+ reference
//! recordings before inference. Feature: `wake-word-dtw`.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! # #[cfg(feature = "wake-word-dtw")]
//! # fn _example() -> Result<(), anyhow::Error> {
//! use rullama_hardware::audio::wake_word::{DtwWakeWordDetector, WakeWordDetector};
//!
//! let mut detector = DtwWakeWordDetector::new();
//! // Enroll 3+ recordings of the user saying the wake phrase
//! // (each 200 ms–2 s of 16 kHz mono i16 PCM):
//! // detector.enroll_template(&recording1)?;
//! // detector.enroll_template(&recording2)?;
//! // detector.enroll_template(&recording3)?;
//! // Then feed live audio in chunks and watch for `Some(...)` returns.
//! # Ok(())
//! # }
//! ```
/// In-house DTW wake-word detector implementation.
/// Pure DTW math over feature-vector sequences (no audio types).
/// Energy-burst wake trigger — zero-dependency fallback.
/// MFCC (mel-frequency cepstral coefficient) feature extractor.
pub use DtwWakeWordDetector;
pub use EnergyTriggerDetector;
pub use MfccExtractor;
/// A wake word detection event.
/// A stateful detector that processes fixed-size audio frames and fires on
/// keyword detection.
///
/// All implementations expect 16 kHz mono i16 PCM. Use
/// [`crate::audio::vad::pcm_to_i16_mono`] to convert an `AudioBuffer` first.