Repository navigation
[Feature] Unsloth Studio / Desktop: Voice mode hears you through any audio-input model, and speaks in the model's own voice where it can - #17069
Conversation
|
Codex review on the fork mirror (LeoBorcherding#671) found no major issues at |
|
Adding the new |
LFM3's byte-level BPE splits an emoji over several tokens; the prefix decoded to U+FFFD, was yielded, and every later decode failed the startswith check, so the rest of the reply text was dropped.
|
@codex review |
Codex Review Summary: ❌ FailedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f87f8dcf5
ℹ️ 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".
| const threadId = useChatRuntimeStore.getState().activeThreadId ?? null; | ||
| const voice = useVoiceSettingsStore.getState(); | ||
| const log = voice.voiceLogEnabled && !(threadId && voice.voiceLogOptOutThreadIds.includes(threadId)); | ||
| return { log, thread_id: threadId }; |
There was a problem hiding this comment.
Attach first-turn voice logs to the eventual chat
With decision logging enabled, New Chat calls the judge and filler before the first composer.send(), while activeThreadId is still null. Those transcript rows are therefore permanently stored with thread_id: null; there is no later association with the created chat. The new chat-deletion and clear-history handlers call voice_log.delete_thread_rows() only with concrete thread IDs, so deleting the conversation leaves its first utterance and held fragments in laya-log.jsonl. Use the pending new-thread ID or associate these rows when the chat is created so they receive the same cleanup as later turns.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Opt-in diagnostic log only; nothing is lost or wrong in the chat, and the log has its own clear. Not changing this here.
…a textless run A voice load next to a managed-engine chat fell through to the primary slot, and orchestrator.load_model shut the vLLM / SGLang chat down first. A run ending with no answer text left the playback stream open, so the player polled forever and queued turns never sent. [skip ci]
|
@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: de825a73f2
ℹ️ 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".
| return generateStudioTtsAudio(sentence, abortRef.current?.signal, { | ||
| // Unnamed: /audio/generate reads with the loaded chat model. | ||
| model: isChatModelVoice(selectedVoiceModelId) ? "" : selectedVoiceModelId, |
There was a problem hiding this comment.
Provide a supported text fallback for MLX chat voices
With an MLX LFM3-Audio/Omni chat, “Chat model’s voice” is offered based on speaks, but a typed turn has no recorded audio and therefore sends its reply through this TTS fallback. The unnamed /audio/generate endpoint cannot read that reply: _generate_tts_wav() explicitly excludes is_mlx speaking chat models. With no separate TTS model loaded, typed replies remain silent and the reload retry repeats the unsupported request. Implement an MLX-compatible text-to-speech path or retain a supported fallback for text-only turns.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MLX has no TTS-mode path for /audio/generate (a backend limit outside this PR); spoken voice turns work there, and a typed turn keeps its text with a visible error. Not adding an MLX TTS path here.
…ply before gen_done, keep a cleared turn's speech out A streamed spoken reply with use_adapter=False left the adapter off for every later request. The audio-input worker sent gen_done while the spoken-reply generator, which holds the generation lock, was still open. STT finishing after a clear refilled the turn audio buffer, so the next turn carried the cleared speech. [skip ci]
With an audio-input model and the mic set to send audio to the model, the composer's clip recorder caught voice mode's listen, so no hands-free turn was ever endpointed, transcribed or sent.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
@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: f1941f5413
ℹ️ 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".
| const status = await getInferenceStatus(); | ||
| if (isChatModelVoice(id)) return Boolean(status.speaks); |
There was a problem hiding this comment.
Query the selected chat slot for its own-voice readiness
With multi-model mode enabled, a speaking LFM3 chat can be selected from an extra slot while a non-speaking model remains primary. Calling getInferenceStatus() without the selected checkpoint reads the primary slot, so this returns false despite chatModelSpeaks() offering the own-voice pick for the selected chat. loadVoice() then fails and submitTranscript() parks microphone turns instead of submitting them. Pass the selected chat checkpoint to the status lookup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Needs a speaking chat model in a kept multi-model slot while another model is primary; the store's speaks comes from the same status. Below the bar for this PR.
…m after a cleared session Ignoring an utterance cleared the whole turn-audio buffer, so the queued question before it went out with its transcript only. A session whose STT finished after a Stop or reset ended without re-arming, since the clear's own re-arm saw it still live. [skip ci]
Main moved the model picker into the composer: part C's embedded picker mode is re-applied on main's ModelSelector, and the voice controls sit after the composer model picker.
|
@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: fecbcea437
ℹ️ 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 (isChatModelVoice(loadedId)) { | ||
| setSpeakers({ family: CHAT_MODEL_FAMILY, values: [...CHAT_MODEL_VOICE_SPEAKERS] }); | ||
| return; |
There was a problem hiding this comment.
Apply the selected speaker to own-voice chat replies
With “Chat model’s voice” selected, the Voice picker offers Male/Female, but selectedVoiceSpeaker is consumed only by useTtsPlayer.synthesize() for /audio/generate. Microphone turns instead request speech through chat-adapter.ts and play delta.audio; neither that request nor _speak_audio_reply() carries the speaker selection. Consequently, changing this visible choice has no effect on hands-free spoken replies. Forward the preference through the spoken-chat path, or do not offer unsupported speaker choices there.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Male/Female drives the model's TTS mode (typed turns read aloud); LFM3's interleaved speech chat has no speaker control in its prompt. Not a correctness bug here.
…'s audio starts in the Start click
The panel's back button starts with the role it shows, the think switch and Start read their hints, Mute and Pause stop stating their state twice, the plus-menu Voice item is a checkbox, speaker choices say which is picked, the voice-log switches and decision search are named, the judge slider reads a percent, and focus rings show where only a tint did. Restoring the full reply keeps focus in the composer.
… are translated The voice-model load toast was hardcoded English. The orb's approval card says why a decision did not go through instead of looking like a dead click. In-progress labels end with an ellipsis. Adds the decision ring's strings in every locale.
…ow under reduced motion The status label is one live region; the faded-out orb leaves the tab order; the help popover is named by its title. The spinner is a CSS spin and the dots are exempt from the reduce-motion freeze, so both slow down instead of stopping; the sound-driven edge stays a circle under reduced motion and skips frames while the chat is hidden. The decision ring and chip are translated.
…x load races Simplify, with no behavior change: shared helpers replace duplicated blocks (_onnx_feed, assertOk, markSpeechStarted, releaseVoiceModels, SizedGlyph, adopt), dead aliases and constants go, and comments are shorter. The voice slot lifecycle moves out of chat-page.tsx into voice-session.ts, which reaches the store, toasts and model loaders only through VoiceSessionPorts (voice-session-store.ts wires them). The voice loop adapter reads the chat runtime and voice settings only through VoiceLoopPorts (voice-loop-store.ts), set by the voice engine before any listen(). Fixes, each with a test that fails on the old code: - A caller joins an in-flight voice load only when it is for the current pick and voice mode has not been turned off since; otherwise it waits and loads afresh, so it is never told a voice is ready when it is not. - A new load waits (up to 10 s) for the unload of the voice that voice off released, so it never sees that voice as still serving. - Voice off while a borrow waits on releasing the old voice leaves the slot unloaded. - A mic request the browser never answers frees the open queue once its session ends; a stream that arrives late is stopped. - React StrictMode's dev remount no longer releases the listening models.
… past, and test the behaviour instead
Restatements, history notes and test-name echoes go; what stays is the non-obvious invariant, ordering rule, unit or external quirk, in one line. Comments only: every touched file has the same tokens (TS) or AST (Python). Co-Authored-By: Claude Opus 5.5 <[email protected]>
When you cut in on a spoken reply, the model got a shorter copy of its reply and no word about why. Now your next message starts with a short note saying where you stopped listening. The chat shows the same note above that message, with a link to use the full reply instead. "Keep only what you heard" is now on by default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # studio/backend/tests/test_vad_audiocpp_sidecar.py
ed6ecbc to
f67b58e
Compare
Cutting in on a spoken reply is now visible to the modelWhen you talk over a voice reply, Studio keeps only the part you actually heard. Before this change the chat showed a small note under the reply, but the model just got a shorter reply with no word about why. Now:
Desktop Phone Commit: 7654398 I also rewrote my earlier commits on this branch and on #14084 so they're credited to my GitHub account. The code is the same, but if you have a local copy of either branch, reset it to the new one. |


The diff includes #12384 and #14084's commits until they merge, and #16976's until it merges.
Hands-free Voice mode hears you through any audio-input chat model, and answers in the model's own voice where the model can speak. Opt-in: the transcript-only (ASR) path stays the default. For #16056, on top of the composer mic setting #16976 adds.
What it does
Two halves, gated separately on the generic capability flags, never on a model family:
has_audio_input, and the mic is set to "Send audio to the model" (Settings → Voice) or the chat model's own voice is the Speak pickaudio_base64) along with its transcriptspeaksand "Chat model's voice" is the Speak pickdelta.audiochunks and plays as it arrivesmodalities: ["text","audio"]) only when its own voice is picked, so it never generates speech that an audio.cpp voice would talk over. Outside voice mode, an audio turn to a speaking model is still answered aloud.speaks. It is never the default, never adopted from a served voice, and a saved pick survives a reload. Picking it releases an audio.cpp voice this page loaded.generatereturned, so the first sound came with the last token. Text tokens and speech frames now come off LFM3'sstreamer/audio_streamer; frames decode through the codec'sLiquidCodecStreamingCachein chunks (4 frames, then 12; 80 ms per frame) and each goes out as its owndelta.audio. A non-streamed reply joins the chunks into one WAV./audio/generate. Asides and thinking fillers are skipped only while the chat model speaks, since they would queue behind the reply on the same model.speech-text.ts,tts-chunk-plan.ts,use-tts-player), unchanged here.Models covered
unsloth/gemma-4-E2B-it-GGUFQ4_K_M, llama.cpp<|audio|>LiquidAI/LFM3-Omni-2B-GGUFQ8_0processor_config.jsonaudio_tokenspeaks), or an audio.cpp voiceclip.has_audio_encoderaudio_configVerified end to end (MacBook Pro M5, macOS 26)
Measured at
673100d514, before this branch moved onto the current part C and #16976's current head; those merges and one edit-hold fix came after and were not re-run in the browser. Unsloth Studio from the branch (isolated install,UNSLOTH_VOICE_MODELS_HUB=Borcherding), voice mode driven in headless Chromium with a scripted mic (macOSsayWAVs over a faint noise floor):modalitieschat-runs)Videos of both turns (picture only, Playwright records no sound): Gemma 4, LFM3-Omni.
With the default settings (ASR, an audio.cpp voice) nothing in the audio.cpp path changes; the ASR row above shows the default turn going out as text only.
Not done: an audio.cpp latency before/after. The run of the existing pipeline on the Colab VM was lost with the VM, and later L4 rentals were reclaimed within minutes of booting.
LFM3 spoken-reply latency (Colab L4)
Measured at
cec6d9819: NVIDIA L4 (23 GB, driver 580.82), Linux, voice mode driven in headless Chromium on the VM with a scripted mic, 4 turns per model. Times are from the end of the user's speech; audio times are when a clip actually starts playing."Endpoint + STT + submit" is the existing listener: ~1.0 s of silence before the turn ends, ~0.5 s of Parakeet, ~0.4 s to submit. "Submit → first audio" includes the loop's 650 ms coalesce window.
Spoken reply over the API alone (
/chat/completions, streamed, warm):Without streaming, the first audio comes with the last token: real-time factor × speech length later, e.g. ~10 s for the 9.7 s reply.
Rough
onnxruntimeand no requirements file lists it, so a fresh install shows "Decide: No module named 'onnxruntime'". The first LFM3-Omni-2B load on MLX cachedaudio_tokenizer/config.jsonbut notaudio_tokenizer/model.safetensors, and the first spoken reply failed with "Missing 100 parameters: decoder.istft.window, …" until that file was fetched.Tests
tests/voice-hears-audio.test.ts(9): ASR is the default; every audio-input family hears the turn in model mode; text-only models never do; the own-voice pick is itself the opt-in; a model still loading hears nothing; thewantsSpokenReplymatrix; the loop and engine use the hearing gate (and an emptied edit drops its speech first); the request useswantsSpokenReply; neither gate names a model family.tests/voice-chat-model-voice.test.ts(10): WAV join, turn audio and coalesced bubbles, spoken-turn detection, markup strip, the pick is opt-in and never default or adopted,speaks, picking it releases an owned audio.cpp voice, speaker lists kept apart.tests/voice-held-edit.test.ts: an emptied edit reports itself once and a sent one doesn't.tests/test_lfm3_spoken_reply.py(5 new): speech streams beforegenerateends, Stop ends it, closing frees the generation lock, the non-streamed route joins chunks, a reply survives a worker still exiting.29b951d828:npm run typecheckclean,npm test15,542 pass / 0 fail. Backend spoken-reply, audio chat load, GGUF models list, chat input audio, TTS routes, audio-token detection, generation budget and adjacent suites: 453 pass.