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
//! MLX local inference backend for Apple Silicon.
//!
//! Provides `MlxSttProvider` for on-device Whisper speech-to-text and
//! `MlxTtsProvider` for MLX TTS model loading.
//!
//! # Whisper STT (`MlxSttProvider`)
//!
//! - **Apple Silicon (`aarch64-apple-darwin`):** runs Whisper locally via
//! `mlx-rs` on Metal GPU with greedy decoding in 30 s windows up to
//! [`MlxSttConfig::max_duration_secs`], automatic mono downmixing and 16 kHz
//! resampling, and a dedicated worker thread so the async runtime never
//! blocks. Building `--features mlx` (or `--features all`) on Apple Silicon
//! requires `cmake` and Xcode's Metal toolchain.
//! - **Other platforms:** `--features mlx` compiles (load-only) and
//! `MlxSttProvider::transcribe` returns `AudioError::Stt` stating Apple
//! Silicon is required.
//! - **Checkpoints:** supports unquantized safetensors checkpoints
//! (`weights.safetensors` or `model.safetensors`), defaulting to
//! `mlx-community/whisper-large-v3-turbo` and supporting
//! `mlx-community/whisper-*-fp16`. `.npz`-only and quantized
//! (`-4bit`/`-8bit`) checkpoints return `AudioError::Stt`.
//! - **Tokenizer:** uses `tokenizer.json` from the model directory when present,
//! otherwise downloads only `tokenizer.json` from the matching
//! `openai/whisper-*` repository based on `config.json` `n_vocab`.
//! - **Language & streaming:** `.en` checkpoints (`n_vocab < 51865`) ignore
//! `SttOptions::language` and use `[sot, notimestamps]`; multilingual
//! checkpoints default to `"en"` when `language` is `None`.
//! `transcribe_stream` returns `AudioError::Stt`.
//!
//! # TTS (`MlxTtsProvider`)
//!
//! `MlxTtsProvider` loads models and tokenizers; inference is not yet
//! implemented (`synthesize` returns `AudioError::Tts`).
//!
//! Requires the `mlx` feature flag.
/// Benchmark and allocation-probe hooks for `benches/` and `tests/`; not a
/// public API and exempt from semver.
pub use bench as __bench;
pub use ;
pub use compute_log_mel_spectrogram;
pub use MlxSttProvider;
pub use MlxTtsProvider;