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
use crateSampleRate;
/// A voice-activity-detection model backend: the minimal per-frame
/// contract the detector needs to turn audio into speech probabilities.
///
/// A backend owns its own recurrent state and rolling context and turns
/// one exact-size frame of PCM into a single speech probability. The
/// backend-agnostic detection logic — [`SpeechSegmenter`], the
/// [`detect_speech_with`] one-shot helper — drives a backend through
/// this trait and never touches the underlying model, so the same
/// segmentation semantics work over the bundled ONNX backend
/// (`Session`, behind the default `onnx` feature) or any other
/// implementation (e.g. a CoreML backend declaring a different frame
/// geometry).
///
/// # Geometry
///
/// [`frame_samples`](VadBackend::frame_samples) declares how many
/// samples make up one frame; the detector advances its timeline by
/// exactly that many samples per probability and chunks incoming PCM
/// accordingly. It is decoupled from
/// [`SampleRate::chunk_samples`] on purpose: the ONNX backend declares
/// `512` at 16 kHz (identical to `chunk_samples`), while a backend built
/// around a different artifact can declare any positive frame size (for
/// example `4096`) and reuse the same detector unchanged.
///
/// [`SpeechSegmenter`]: crate::SpeechSegmenter
/// [`detect_speech_with`]: crate::detect_speech_with