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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
//! VAD per-domain load entry points, ported from
//! [`mlx_audio.vad.utils`][vad-utils].
//!
//! Faithful 1:1 of mlx-audio's two-tier shape:
//!
//! - [`load_model`] ([vad-utils.py:14-36][vad-utils-loadmodel]) — the
//! inner factory call mlx-audio funnels into
//! `base_load_model(model_path=…, category="vad",
//! model_remapping=MODEL_REMAPPING, …)`.
//! - [`load`] ([vad-utils.py:39-64][vad-utils-load]) — the **main entry
//! point**; thin alias over [`load_model`] (`return load_model(...)`).
//! Carried as a separate function because mlx-audio's public surface
//! carries both — the documented call site is `from mlx_audio.vad
//! import load`.
//!
//! mlx-audio's `MODEL_REMAPPING` table ([vad-utils.py:8-11][vad-utils-remap])
//! routes per-architecture aliases (`silero` → `silero_vad`, `silero-vad`
//! → `silero_vad`) into the `mlx_audio.vad.models.<arch>` namespace; per
//! the no-per-model-arch rule mlxrs returns a [`VadModel`] trait object
//! (`Box<dyn VadModel>`) the per-architecture loader's caller constructs
//! itself, so the remap table is the **caller's** responsibility — this
//! module documents the mlx-audio names in [`MODEL_REMAPPING`] for
//! parity but never imports an arch crate.
//!
//! [vad-utils]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py
//! [vad-utils-loadmodel]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L14-L36
//! [vad-utils-load]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L39-L64
//! [vad-utils-remap]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L8-L11
use crate::;
/// The mlx-audio `MODEL_REMAPPING` table for VAD architectures
/// ([vad-utils.py:8-11][vad-utils-remap]) — a static array of
/// `(alias, canonical_module_name)` pairs.
///
/// **Reference-only**: per the no per-model arch porting rule,
/// mlxrs does NOT import per-architecture crates from this table — it
/// exists purely so an end-of-pipeline caller (who DOES wire in concrete
/// architectures) can mirror mlx-audio's alias resolution. Add new
/// aliases here when the upstream table changes.
///
/// [vad-utils-remap]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L8-L11
pub const MODEL_REMAPPING: & =
&;
/// The trait every per-architecture VAD model implements — the analogue
/// of mlx-audio's per-arch `Model` class's
/// [`generate(audio, sample_rate=…) -> VADOutput`][vad-generate] method.
///
/// Per the no per-model arch porting rule, mlxrs ships no
/// concrete VAD models; this trait is the *shape* per-architecture
/// crates (silero_vad / sortformer / smart_turn / …) implement so a
/// caller can hand-off any VAD architecture as a `Box<dyn VadModel>`
/// from the [`load`] / [`load_model`] entry points.
///
/// `&self` because weights are immutable after load (matching every
/// other audio-domain trait in mlxrs — [`crate::audio::tts::model::TtsModel`]
/// / [`crate::audio::stt::model::Model`] — and mlx-audio's `nn.Module`
/// for inference).
///
/// [vad-generate]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/models/silero_vad/silero_vad.py#L243-L266
/// Construct a [`VadModel`] from a local on-disk model directory —
/// faithful 1:1 of `mlx_audio.vad.utils.load_model`
/// ([vad-utils.py:14-36][vad-utils-loadmodel]).
///
/// Routes through the shared
/// [`crate::audio::load::base_load_model`] factory (the analog of
/// mlx-audio's `return base_load_model(model_path=…, category="vad",
/// model_remapping=MODEL_REMAPPING, …)`). The returned
/// [`LoadedAudioModel`] bundle (model dir + verbatim config.json +
/// optional [`crate::lm::quant::PerLayerQuantization`]) is handed to
/// `constructor` — a caller-supplied closure that builds the concrete
/// per-architecture [`VadModel`] (the analog of mlx-audio's
/// `model_class.Model(model_config) + load_weights(...)`); per the
/// no-per-model-arch rule mlxrs does not bundle a built-in registry.
///
/// `path` is the local on-disk path (a `hf://…` / `org/name` repo id is
/// rejected by [`crate::audio::load::get_model_path`] with a clear
/// no-network message; see that function's docs).
///
/// Failures are typed: missing dir →
/// [`Error::MissingKey`](crate::error::Error::MissingKey), hub path →
/// [`Error::OutOfRange`](crate::error::Error::OutOfRange), malformed JSON →
/// [`Error::Parse`](crate::error::Error::Parse), constructor
/// error → caller-defined.
///
/// [vad-utils-loadmodel]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L14-L36
/// The **main entry point** for loading a VAD model — faithful 1:1 of
/// `mlx_audio.vad.utils.load` ([vad-utils.py:39-64][vad-utils-load]),
/// the thin alias over [`load_model`] mlx-audio's `from mlx_audio.vad
/// import load` call site uses.
///
/// Carried as a separate function because mlx-audio exposes it as
/// part of its documented public API
/// ([`mlx_audio.vad.__init__`][vad-init]: `__all__ = ["load",
/// "load_model"]`); mlxrs mirrors the two-name surface for parity.
///
/// [vad-utils-load]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/utils.py#L39-L64
/// [vad-init]: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/vad/__init__.py