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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use crateSampleRate;
/// A voice-activity-detection model backend: the push-based contract the
/// detector drives to turn audio into speech probabilities.
///
/// A backend owns its own recurrent state, rolling context, and input
/// windowing. It accepts PCM through [`push`](VadBackend::push) and emits
/// zero or more speech probabilities per call by invoking a `sink`
/// callback — one probability per model frame the backend completes. 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 any backend implementation: an ONNX Silero backend
/// whose analysis window equals its hop (512 samples at 16 kHz), a backend
/// with overlapping analysis windows (a 400-sample window advanced by a
/// 160-sample hop), or a purely synthetic one.
///
/// # Geometry
///
/// Input windowing is the backend's private business: one
/// [`push`](VadBackend::push) may complete zero, one, or many frames, and
/// successive analysis windows may overlap. The detector only needs
/// [`frame_hop`](VadBackend::frame_hop) — the number of samples one emitted
/// probability advances the timeline. For a backend whose window equals its
/// hop this is just the frame size (`512` for Silero at 16 kHz); for an
/// overlapping-window backend it is the hop (`160`), not the window
/// (`400`). It is decoupled from [`SampleRate::chunk_samples`]: the Silero
/// geometry declares `512` at 16 kHz (identical to `chunk_samples`), while
/// another artifact declares whatever hop its frames advance by and reuses
/// the same detector unchanged.
///
/// # End of stream
///
/// [`finish`](VadBackend::finish) marks end-of-stream and lets the backend
/// apply its own trailing-frame policy: a backend that zero-pads its last
/// partial frame emits one final probability; a backend that drops an
/// incomplete trailing window (`snip_edges`) emits nothing. The detector
/// imposes neither policy — it drives [`push`](VadBackend::push) over the
/// input, then [`finish`](VadBackend::finish), and segments whatever
/// probabilities the backend chose to emit.
///
/// [`SpeechSegmenter`]: crate::SpeechSegmenter
/// [`detect_speech_with`]: crate::detect_speech_with