Repository navigation
Studio: transcribe with downloaded MLX speech-to-text models on Apple Silicon - #13443
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Two reds on this head (
|
…d MLX translation
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a32bf52c4e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if isinstance(engine, _MlxSttModel): | ||
| text, consumed = transcribe_mlx_window(engine, command["audio"]) |
There was a problem hiding this comment.
Make MLX generation observe transcription cancellation
When an MLX transcription is stopped while generate() is still running, this branch does not pass the shared cancellation event into the MLX call; it is checked only after generation returns. For any window that runs longer than the worker's cancellation grace period, _await therefore terminates the entire child, evicting the resident model and forcing the next transcription to reload it, whereas the Whisper branch stops generation cooperatively. Poll cancellation through MLX streaming or a generation callback so Stop can preserve residency.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: a window is at most 30 s of audio and Qwen3-ASR on Metal finishes one in a few seconds (38 s clip in 6 s on macos-15), well inside the 10 s cancel grace, and when it is exceeded the outcome is a reload on the next request, not lost or wrong output.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b122a98ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| macMlxSttRowIsRunnable({ | ||
| isMac, | ||
| isStt: c.task === "automatic-speech-recognition", | ||
| isGguf: false, | ||
| libraryName: c.library_name, |
There was a problem hiding this comment.
Honor non-active cache paths for MLX STT rows
When this checkpoint exists only in a legacy or otherwise non-active Hugging Face cache, the inventory intentionally supplies an absolute c.load_id, but this new gate still offers the row while the STT selection path discards meta.loadId and passes only the repository ID to ensureSttLoaded. The backend then searches only _active_hf_hub_cache(), reports the displayed model as not downloaded, and its remote download path cannot recover because validation still accepts only Whisper; either restrict this gate to active-cache rows or carry the pinned snapshot identity through the STT load.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing here: the Transformers dictation engine resolves every custom repo (Whisper included) in the active cache only, and a custom Whisper row from a legacy cache behaves the same on main today. Carrying load_id through STT loads is a separate change for both engines.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a179564e48
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| hint = _mlx_language(engine.model, language) | ||
| result = engine.model.generate(segment, **({"language": hint} if hint else {})) | ||
| text = getattr(result, "text", result) | ||
| return (text if isinstance(text, str) else ""), len(segment) |
There was a problem hiding this comment.
Preserve speech across MLX window boundaries
When an MLX transcription exceeds 30 seconds and the three-second lookback contains no qualifying silence, the sidecar hard-cuts the audio at the window boundary. Returning len(segment) here marks that entire chunk as consumed, while MLX provides no timestamps or overlap, so a word or utterance spanning the cut is decoded independently on both sides and can be omitted or mangled. Use overlapping MLX windows or let Qwen3-ASR perform its native long-audio chunking rather than consuming every hard-cut sample.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: windows already end at the quietest 100 ms inside the last 3 s, so a hard cut needs 3 s of speech with no pause at all at a 30 s mark, and the cost is at most a word there. Bigger or native-chunked windows would push 30 min of PCM through one queue message and lose per-window progress and cancel, which the sidecar keeps on purpose.
…ter repair, map languages without transformers
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #10272
Problem
On a Mac, a speech-to-text model downloaded in MLX format (for example
mlx-community/Qwen3-ASR-1.7B-8bit) never shows up in the Transcribe tab. The Transformers dictation engine only accepts Whisper checkpoints, and the Transcribe picker only admits Whisper rows from the cache, so the model is invisible there (the cache listed it as a chat model instead).Fix
mlx-audio already ships with the Mac install (mlx-vlm depends on it), so the existing Transformers dictation engine now serves these checkpoints through it on Apple Silicon:
core/inference/stt_mlx.py: one predicate, true only on Apple Silicon with mlx-audio installed, forqwen3_asrcheckpoints (the family Studio already curates as GGUF). mlx-audio loads both the mlx-community quants and the original Qwen safetensors. Whisper never goes this way.The sidecar accepts such a cached snapshot and starts the same spawned dictation worker with
runtime="mlx"; the child loads it withmlx_audio.stt.loadand transcribes each window. Load, idle unload, cancellation, residency, status, the CPU audio preference and the frontend engine are the existing Transformers ones, so nothing new is exposed to the UI.The Hugging Face cache inventory lists the repo as
automatic-speech-recognitionwith librarymlx-audioand not chattable, and the Transcribe picker admits that on-device row on a Mac only.The language picked in Transcribe is passed to the model when the checkpoint lists it in
support_languages; otherwise the model detects it.A snapshot that ships its own code (any
.py, or anauto_mapin its configs) is refused before loading, since mlx-audio loads the tokenizer withtrust_remote_code=True.These checkpoints do not translate, so
/audio/translationsrefuses them with the existing 400 instead of returning a transcript.Qwen3-ForcedAligner checkpoints (also
model_type: qwen3_asr) are excluded: they align a given transcript and cannot transcribe.Picking such a cached model from the Chat model picker routes it to Transcribe, as it already does for Whisper.
The mlx-audio check caches only a positive answer, so a session where the MLX self-repair installed mlx-audio picks it up without a restart.
What does not change
Testing
Real Apple Silicon (GitHub
macos-15, Metal), Studio's Mac pins (mlx 0.32.3, mlx-lm 0.31.3, mlx-vlm 0.7.4, mlx-audio 0.5.8, transformers 5.5.0),mlx-community/Qwen3-ASR-0.6B-8bitin the Hugging Face cache, speech rendered by macOSsay, the tree's own inventory scan and dictation sidecar with nothing patched. The merge base and this branch ran on the same runner:automatic-speech-recognition, librarymlx-audio, not chattableSTT model 'mlx-community/Qwen3-ASR-0.6B-8bit' is not downloaded. Download it in Settings, then Voice, before loading it.In the beginning, God created the heaven and the earth.(all words)mps, released on unloadThe MLX training smoke job (
Qwen3.5-2B-4bit, 5 LoRA steps) also passes on the same leg.Unit and regression coverage:
studio/backend/tests/test_stt_mlx.py(28 tests, green on macOS, Ubuntu and Windows, and with torch, PyAV and transformers absent): host gate, family gate, snapshot acceptance on and off a Mac, worker command routing, no in-process Whisper fallback for MLX, child load and transcribe, a real spawned worker end to end through the sidecar windowing with mlx-audio stood in, the cache scan row and inventory flags on and off a Mac. With the functional hunks reverted, 8 of them fail.studio/frontend/tests/audio-picker-policy.test.ts: picker gate (35/35 on all three OSes). Frontend typecheck and the full frontend suite (11757 tests) pass locally.Genesis 1:1, in the beginning, God created the heaven and the earth.; onmainthe same snapshot reads as not downloaded.Transcribe picker, Apple Silicon
Merge base vs this branch, each built from source on the same
macos-15runner withmlx-community/Qwen3-ASR-0.6B-8bitin the Hugging Face cache, Audio > Transcribe > model picker > On Device. Before: "No downloaded models yet." After: the model is listed and can be picked.