Skip to content

Unsloth Desktop: hands-free Voice mode in chat that listens and speaks through audio.cpp, kept loaded beside the chat model - #12384

Open
LeoBorcherding wants to merge 150 commits into
unslothai:mainfrom
LeoBorcherding:voice/pr-a-conversation-mode
Open

LeoBorcherding wants to merge 150 commits into
unslothai:mainfrom
LeoBorcherding:voice/pr-a-conversation-mode

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Merge order: this PR (part A) lands first. #14084 (part C) is stacked on it, and #17069 on #14084 and #16976. #12385 (part B, the latency benchmark) is independent and lands in any order.

Voice mode for chat in Unsloth Desktop, rebuilt on the current audio stack: it listens with audio.cpp and speaks with audio.cpp. This replaces the whisper.cpp and llama-server design from #6527. This is part A.

What it does

  • The + menu gets a Voice toggle that opens the voice orb. A turn ends after 1 s of silence and is transcribed and sent automatically. The reply is spoken sentence by sentence while it streams.
  • Speaking during the reply stops it, and what you said becomes the next turn. Esc or "Back to chat" hides the orb but keeps the loop going. Turning Voice off stops everything and unloads the voice.
  • Pickers in the header choose the speech-to-text model (default Parakeet-TDT-0.6B-v3) and the voice (default Kokoro-82M, or any audio.cpp speak model). Saved Audio voices appear for models that can clone.

How

  • The voice loads with voice: true. That keeps it in an extra model slot next to the chat model even with multi-model off; with no room it gets a 409 and never replaces the chat model. /load refuses the flag with a 400 unless the model resolves to an audio.cpp speech or transcription model. The load is announced as a chat-side load.
  • If the GPU memory check refuses the voice, it loads on the CPU.
  • Speech uses /api/inference/audio/generate with model and an optional voice_id, at most two clips queued. Listening uses /api/inference/audio/transcribe/raw.
  • Barge-in: the echo-cancelled mic stays open during playback. The threshold is max(0.045 RMS, 3x the leak measured during this reply), held for 220 ms, with a 300 ms pre-roll so the first word isn't lost.
  • Turning Voice off mid-sentence unloads with force_cancel_active, so a sentence still being synthesized can't keep the voice loaded.
  • The voice code is one lazy chunk, and nothing from it mounts until the first Voice click. That click also unlocks audio playback.
  • Removed: the streaming Orpheus route, the llama-server voice slot, the whisper.cpp dictation path, and their tests. Backend files outside voice match main.

Verification

check measured at result
frontend tsc, npm test fb92d2c clean; 12,510/12,510
backend test_multi_model_serving.py fb92d2c 85 passed
backend pytest, head vs main 565630c fe1db32 (backend outside the voice check unchanged since) 3933/12/50/30 vs 3931/12/50/30, same failures; +2 are the new slot tests
bundle:check fb92d2c passes, 95 chunks
Unsloth Desktop drive, Ryzen 5 2600 + RX 6500 XT 4 GB, Windows 11, Qwen3-1.7B UD-Q4_K_XL on llama.cpp, Kokoro on audio.cpp CPU b2a505a question, follow-up, 25-word prompt, 0.8 s mid-sentence pause, barge-in, silence, exit mid-reply, no model: all behave as described
before (main 565630c), same box no Voice entry; dictation needs a manual send; read-aloud is a click per message

The drive predates the lazy-mount and click-replay changes in fb92d2c; those are covered by unit and source tests, not a re-drive.

Latency on that box: median 24 s from end of speech to first audio. Speech-to-text is 1.5 to 3.8 s, the LLM 4 to 19 s with thinking on, and the first sentence's CPU synthesis 9 to 11 s.

Coverage. Correctness here depends on the device the voice lands on, and hosted CI has no audio device or GPU, so this table is the test report.

setup what ran still needed
Windows 11, AMD RX 6500 XT 4 GB, voice on CPU (fallback) full drive above
voice on GPU (Vulkan/CUDA) not run: the 4 GB card is refused by the memory check a card with ~2 GB free next to the chat model
real speakers and a real mic not run: the fake mic gets no echo echo cancellation against speaker leak, and barge-in while audio is playing
Linux, macOS, NVIDIA not run

Bottom line: the full turn loop, loading next to the chat model, the CPU fallback and exit cleanup are verified on Windows AMD. The biggest gap is barge-in with real speakers while audio is actually playing.

Known, outside this PR: cancelling an audio.cpp request restarts audiocpp_server, so the reply to a barge-in waits about 13 s longer on CPU. There's no mute control yet; Esc only hides the orb.

Before / after (Studio built from main and from this branch)

Chat + menu, before and after: Voice is the only new item

The voice orb during a real spoken turn: warming up, writing the answer, speaking, listening again

Fixes #17822

donaldfilimon and others added 26 commits September 4, 2026 04:57
Rebuilds PR unslothai#6527 on today's main. The branch was cut from 2026-06-23 and main
has since landed its own audio stack, so roughly two thirds of the original diff
is now duplicate work and is dropped rather than merged:

- routes/audio.py in full. /audio/speech, /audio/transcriptions and the STT
  sidecar family already exist on the inference router, dual-mounted under /v1,
  monitored and body-capped. Streaming is added there as /audio/speech/stream
  instead of on a second router, so it inherits all of that.
- audio_type on LoRAInfo, detect_audio_type_from_local, and the scan_loras
  threading: superseded by audio_type/audio_type_known and
  detect_audio_type_checked.
- the Listen modal for trained TTS LoRAs: the Audio page lists and plays them.
- the Whisper dictation adapter, STT engine toggle, STT model selector and mic
  picker: superseded by StudioDictationAdapter, StudioModelDictationAdapter and
  the voice-settings store.
- Qwen3-TTS: an independent optional backend with an on-demand pip install,
  deferred to its own PR.

What is left is the part main does not have: a speech-to-speech conversation
loop, and a second llama-server "voice slot" so a TTS model can stay resident
beside the chat LLM. _generate_tts_wav prefers that slot when it is loaded, and
AudioSpeechRequest.voice is now honoured for named-speaker codecs instead of
being accepted and ignored.

The frontend half lands as its own module, features/chat/voice/: the loop and its
composer control in voice-engine.tsx, the orb's priority order as a pure tested
function in orb-state.ts, and the cross-remount registry in voice-loop-bridge.ts.
thread.tsx keeps the two mount points and the plus-menu item, +53 lines against
main rather than +751, so this path can be read, reviewed and reverted on its own.

Review findings addressed:
- /voice/load now runs _guard_chat_load_against_training, so enabling a voice
  during training is refused rather than placing another model (P1). It runs it
  through _offline_guarded, the way /load does.
- the shared audio codec is reference-counted, so unloading one slot no longer
  frees the codec the other is still decoding through. A manager nobody claimed
  is still freed, so a load cancelled between constructing it and claiming it
  does not leak it.
- each llama-server slot writes its own pidfile and the reaper sweeps them all;
  previously the second slot overwrote the first's record. The slot key is read
  off the instance rather than passed in, so _record_server_pid keeps the exact
  signature it has always had.
  Restoring that signature is also what keeps this branch from touching a single
  upstream test: an earlier draft widened it and broke the neutralising stubs in
  the shared llama_cpp placement fixture, which 46 test files reach through.
- voice mode is gated on the streaming speech-recognition engine, not on TTS
  alone, so it cannot be entered where no transcript can ever be produced.
- the silence timer no longer auto-sends while TTS is audible, which was posting
  echo of the model's own voice as the user's next message.
- switching the chat model to a speech-LLM now clears and unloads the separate
  voice slot instead of only greying out the picker.
- audio priming plays a real silent source, so the first clip is not refused by
  autoplay policy.
- browser-speech completion is tied to its request id, so a cancelled utterance
  cannot end the new one early.
- when the backend produces no audio for a whole reply, it falls back to browser
  speech rather than going silent.

Found while porting: the streaming path bypassed neutralize_tts_prompt_text
(unslothai#7066) and chose a decode device without consulting holds_no_vram; both fixed.
The TTS player read the store's voiceSlotLoaded through a local shadow that
meant "a voice is selected", so the first synth of a turn could POST into a slot
that had not finished loading. The voice download path sized itself off
size_bytes where every other download path uses download_size_bytes ||
size_bytes, which under-reports a sharded GGUF. The PCM player assumed 24 kHz
instead of reading the X-Sample-Rate header the stream route already sends.

Not verified end to end: this needs a GPU, a llama-server, TTS weights and a
browser, none of which were available, so no claim is made that the loop
speaks. What did run, on macOS against the CI commands: ruff 0.15.12, compileall,
the four custom linters, tsc -b plus the test project, the strict i18n parity
check, the frontend unit suite (6,858 pass), vite build, the bundle budget, and
the backend pytest suite in both its parallel and serial passes. Every backend
failure left on this machine reproduces identically on origin/main.

Co-authored-by: Bardia Koopah <[email protected]>
Co-authored-by: LeoBorcherding <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TSaSnTn9AUf4wPbCaTTykW
…ion engines

Voice mode was offered only when Settings -> Voice was set to the browser's Web
Speech engine, and hidden otherwise. Under Tauri the default is "model", so the
desktop app never showed Voice at all.

The reason was real: the loop's turn-taking watches the transcript grow, and a
batch engine ("model" or "custom") returns one transcript when the session ends,
so nothing grows and the 1.5s silence timer would close the mic and find an empty
composer every time. The loop now owns end-of-utterance for those engines
instead, from the microphone meter both adapters already publish through
startDictationLevelMeter. No change to any adapter.

- 900ms of quiet after real speech ends the turn: above the model adapter's own
  280ms segment cut, below the streaming engine's 1.5s. Quiet before the user has
  said anything is just the room, so an idle mic listens indefinitely.
- the same meter drives voiceHearing for BOTH engines, and closing the mic sets
  voiceTranscribing. Those two store fields had readers and orb states but no
  writer anywhere; this supplies them.
- submitTranscript, which was written for this path and unreferenced, is what
  sends the result, so a batch turn takes exactly the same send, coalesce and
  re-arm path as a streaming one.

Barge-in is deliberately NOT wired for the batch engines, and the mic is not
armed during playback for them either. Their session records continuously and
transcribes the whole recording on stop, so a mic open while the model speaks
would post the model's own words back as the user's next message, and a
transcript that only arrives at the end cannot be echo-checked after the fact.
The streaming engine survives this because its barge-in requires the transcript
to grow and its silence timer drops anything heard while audio is audible.
Doing it properly needs acoustic echo cancellation on the capture stream. Until
then the batch loop is listen, transcribe, generate, speak, listen again.

Unexercised: this needs a microphone and a browser. It typechecks, builds, and
the unit suite is green, and that is the whole of the claim.

Co-authored-by: Bardia Koopah <[email protected]>
Co-authored-by: LeoBorcherding <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TSaSnTn9AUf4wPbCaTTykW
…e event loop

Review follow-ups on the voice slot (PR unslothai#10373):

- Training coordination now sees the voice slot. summarize_resident_chat()
  reports it under a new "voice" key and counts it toward "any"/"loading",
  and free_chat_models_for_training() unloads it in its own isolated block
  (voice:<name>), with the same CPU-only exemption as the chat slot. Without
  this a training start could unload the chat model and launch beside a
  second llama-server it never knew about. Covered by six new cases in
  test_training_vram_coexistence.py; _patch_backends grows a voice= stub.
- /voice/load resolves ModelConfig.from_identifier() via asyncio.to_thread
  under _hf_offline_if_unreachable_for, exactly as /load does, instead of
  scanning the HF cache on the event loop.
- /voice/unload and both /voice/load error-path teardowns run unload_model
  through asyncio.to_thread, as /unload does.
- /audio/speech/stream refuses IQ1/IQ2/Q2 Orpheus quants with a 400 before
  the monitor row opens: the spoken-name trim needs the whole clip, and the
  client already falls back to the blocking route on a non-OK response.
- The stream's read timeout stays flat, now documented and expressed via
  _GGUF_AUDIO_READ_TIMEOUT: httpx applies it per socket read, so on a
  token-by-token stream it bounds a stall between tokens, not the whole clip.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…voice loop

Review follow-ups on the conversation loop (PR unslothai#10373):

- A PCM stream that scheduled nothing (network failure, or a 200 that closed
  before its first chunk) now resolves as unplayed, so the caller falls back
  to the blob path and then the browser voice instead of advancing the loop
  in silence. A superseded request still reads as played, so a barge-in
  never triggers a fallback.
- speak() ends the turn (onPlaybackEnd) when normalization strips the whole
  reply, so an emoji-only answer no longer leaves voice mode with a dead mic.
- Browser-speech onend/onerror ignore events from a request that is no
  longer current, so a cancelled utterance's late error cannot cancel the
  replacement reply's queue.
- The coalesce timer re-arms while the barged-in run is still settling
  (bounded, ~10s) and only starts a run behind a trailing user bubble, so the
  appended bubbles get their reply once cancelRun() completes.
- A spoken utterance clears only the active thread's prompt queue via the
  new resetPromptQueuesForThread; resetPromptQueues is module-private again.
- useVoiceAvailable gates on listening alone: the picker always offers a
  local GGUF voice and the browser voice ends the turn cleanly without
  speechSynthesis, so the old TTS half hid the menu where the local voice
  was the only way to speak.
- Speech-LLM detection reads the model record's audioType first and falls
  back to the name pattern, so a renamed fine-tune still clears and unloads
  the voice slot. It lives in a dependency-free voice/speech-llm.ts with the
  codec sets moved to voice/tts-audio-types.ts (re-exported unchanged from
  use-tts-player), and has a node:test suite.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… voice n_ctx

Second review round on the voice slot (PR unslothai#10373):

- /audio/speech/stream joins _INFERENCE_SUFFIXES. The tuple is an endswith
  test and the route ends in /stream, so the /audio/speech entry never covered
  it: with the stream as the only inference in flight, an API-key training
  start saw other_inference_request_count() == 0, unloaded the voice backend
  and cut the live PCM clip off instead of returning 409. Now that the route
  is tracked, its generator's swallowed-error arm also flags the response
  failed (mark_current_response_failed), since it ends the stream cleanly at
  200 and the middleware would otherwise read a failed clip as a completion
  that claims a preview-owned chat slot.
- _VoiceLoadRequest.n_ctx takes the same MAX_REQUESTABLE_CONTEXT ceiling as
  LoadRequest.max_seq_length. The handler models the load as a chat
  LoadRequest for the training-coexistence guard, so an oversized value used to
  pass validation and then fail inside the handler as a 500, after the HF
  resolve, instead of a 422 up front.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…pened

Two defects found uncommitted in the working tree.

The voice model selector expanded GGUF entries with `onDevice`, which
honors the global "Show all quantizations" setting (off by default) and
lists only quants already on disk. On a fresh install the uncached default
voice therefore expanded to "No GGUF variants found" and its first-use
download could never start. Every row downloads a missing quant on pick,
so the browse listing is the correct one here.

VoiceEngine called endStream unconditionally at run end, including for a
run that began before the user switched voice mode on — where no TTS
session was ever opened. Track whether the run-start branch actually
opened one and flush only then.

Verified with `npm run typecheck` in studio/frontend (exit 0). This is a
third-party upstream clone with no local gate of record; upstream CI
remains the real gate for the Python side.

Co-Authored-By: Claude Opus 5 <[email protected]>
…e the loop's half-duplex gaps

Running this branch in the desktop app, the loop cut its own reply about a word
in and left empty transcripts flickering through the composer. The causes were
all on the listen/speak boundary, so this brings back the unslothai#6527 frontend that
owned it and fixes what the port exposed.

Restored from unslothai#6527:

- StudioWhisperDictationAdapter, which owns a turn end to end: capture, energy
  VAD with two-threshold hysteresis, transcribe, commit, re-arm. Rebased onto
  the current stack, so it resolves models through the STT registry
  (loadSttModel / requestSttDownload / transcribeAudioBlob) instead of letting
  the backend pick, which was 400ing on an undownloaded 'small'.
- The streaming TTS player, whose replacement clipped audio between sentences.
- The STT model and microphone pickers, repointed at the current model-selector
  components and the renamed store fields.
- The sentence chunker, now in its own dependency-free module so it can be
  tested without pulling in React and auth. It keeps abbreviations, decimals,
  initials and closing quotes attached, and stripForSpeech no longer collapses
  the newlines the splitter needs, which had made a multi-paragraph reply one
  synth request. Nine tests cover it.

Fixed on top:

- resumeListen had no half-duplex guard. On a batch STT engine the mic re-armed
  during playback, heard the model through the speakers, and tripped the
  adapter's own barge-in ~220ms in. It now defers the re-arm (rather than
  dropping it, which would dead-end the loop) until generation and playback are
  done, and energy barge-in is ignored on batch engines, matching the rule
  already written into armDuringTts.
- An empty transcript went down the barge-in path and called stop() before the
  emptiness was checked, so a silent turn cut audio that was still playing.
- Streaming synthesis was strictly serial: each sentence waited for the previous
  one to finish *playing*, and voiceParallelN never reached that path at all, so
  a configured voice slot sat with an idle llama-server slot. Sentences now
  generate up to voiceParallelN ahead, gated so they still schedule in order,
  onto one shared playhead -- the jitter buffer is paid once per reply instead of
  at every sentence boundary. N=1 collapses to the old serial behaviour.

The blob fallback is gated on the same chain: a Q2 Orpheus quant is refused
streaming by the backend and 400s in milliseconds, so an ungated window would
start every sentence's fallback at once and stamp them over each other on the
shared audio element.

Not verified: the audible result on hardware is the reporter's to judge; there
is no mic or speaker in CI. Typecheck is clean and the frontend suite passes.
Resolves the five conflicts against upstream main. The one Daniel asked about
is `_pid_slot` against main's new spawn locking (unslothai#10592):

- `llama_cpp.py`: main's `_spawn_lock` / `_teardown_lock` and the locked spawn
  blocks are taken whole, with the PR's slot-aware `_record_own_server_pid`
  substituted for `_record_server_pid` at both call sites. Main never changed
  the pid-helper definitions, only moved the call sites under the lock, so the
  two changes compose rather than compete. The chat slot keeps the identical
  single-argument path and the identical pidfile path (`_slot_pidfile_path("")`
  returns the base path), so startup reaping is unchanged when no voice slot has
  ever been recorded.
- `audio_codecs.py`: main's `_load_snac(model_repo_path)` signature, plus the
  PR's `has_codec`.
- `routes/inference.py`: main's `requested_model` budgeting and `require_speech`
  switch are taken whole and wrapped in the PR's voice-slot guard, and the guard
  now also requires that no model was named. A caller that names a model keeps
  main's path exactly: the voice slot owns speech only for the resident-model
  form, which is what voice conversation mode sends.
- `check-bundle-budget.ts`: main's re-measured budget, not the PR's older raise.
- `thread.tsx`: main's dock inset and dictate-button sizing, with the PR's
  `voiceOrbActive` z-index and voice-mode wrapper.

Co-Authored-By: Claude Opus 5 <[email protected]>
…dent-model form

The main merge takes main's named-model switch in _generate_tts_wav and wraps
it in the voice-slot guard, and the guard now also requires that no model was
named. Nothing pinned that seam: the existing pre-switch-budget test runs with
no voice slot loaded, so it could not tell a bypass that ignores a named model
from one that honours it. The conversation loop sends {input, voice} with no
model, so it takes the voice slot; a named /v1/audio/speech request reaches the
switch even with the voice slot loaded.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…stored frontend

Of the ten review threads left unresolved on unslothai#10373, six were already fixed at
the head (voice teardown and metadata off the event loop, /audio/speech/stream
tracked by llama_keepwarm, n_ctx bounded by MAX_REQUESTABLE_CONTEXT, the
coalesced run retried until cancelRun settles, the mid-run activation speaking
the finished reply, the default voice's variants offered as a browse listing).
The other four needed code, two of them because the unslothai#6527 frontend restoration
(8d4141a) rewrote the TTS player and dropped fixes that had landed in 5a41376:

- use-tts-player.ts: an emoji-only or markup-only reply ends the turn again
  through onPlaybackEnd instead of returning with the mic shut; the browser
  branch is the guarded speakWithBrowser again, so a cancelled utterance's
  late onend/onerror cannot cancel the replacement reply's queue.
- use-tts-player.ts: a sentence the backend fails to synthesize mid-reply is
  spoken in order with the browser voice (speakSentenceWithBrowser) at all four
  playback sites, instead of being dropped while the loop advances as though it
  had been spoken. stopSynth() cancels it on barge-in like any utterance.
- chat-page.tsx: /voice/load takes an attempt number; a download rollback, a
  failure, or a success that no longer holds the current number leaves the
  store alone, and loads are serialised on the in-flight request so the last
  pick is the last one llama-server sees.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… voice load

Picking the browser voice while a voice was still loading fired /voice/unload
at once, so the unload could race the load on the backend and the voice it was
loading came up under a store that says browser voice. The unload now waits for
the in-flight request and re-checks that browser voice is still the pick, the
same fence the load path already had.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…re resolving

Main's per-account isolation (unslothai#10588) gates /load and /validate on
account_access.require_model_access and replaces an absent hf_token with the
account's own before any resolution. /voice/load, written before that landed,
resolved the caller's identifier with the caller's token first, so in a
managed-account install the voice slot was a second door past both the grant
check and the ambient-credential rule. Same two calls, same order, up front.
Two tests: a denied grant is a 403 before ModelConfig.from_identifier runs, and
a permitted load resolves with the account token rather than the caller's.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Resolves two conflicts against upstream main:
- llama_cpp.py: keep main's rule that the pidfile is cleared only once the
  child's exit is confirmed, and clear this backend's own slot pidfile
  (_clear_own_server_pid) rather than the chat slot's.
- thread.tsx: keep main's --ui-space-scale composer-dock inset and the
  branch's voice-orb z-index lift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HdL6vCyq1LbkqH3WpH9mMz
…ast setting

Main's contrast-slider test now rejects fixed-alpha washes in chrome. The
voice and STT model selectors drew their separators with bg-black/[0.08]
and bg-white/[0.08]; they now use the gain-aware spelling the chat settings
sheet already uses for the same separator, which resolves to the same colour
at the default contrast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HdL6vCyq1LbkqH3WpH9mMz
…live across chats

Browser speech is gone from the conversation loop. "Browser voice" and
"Browser" listen are removed from the header pickers, the loop always uses
a local transcription model and the voice slot, and the speechSynthesis
fallback in the player is gone: a sentence the slot cannot synthesize now
toasts once instead of switching to a system voice mid-reply. The Dictate
button's own browser engine in Settings is untouched; the no-speech hook
this PR had added to the web-speech adapter is reverted since nothing in
voice mode reaches it any more.

Opening voice with no chat model used to arm the mic and sit on
"Listening" with nothing to answer. The orb now has a "waiting" state
("Select a model"), the mic stays shut, and it arms itself when a model
loads. Starting a new chat no longer turns voice off: the thread-switch
reset cuts the old turn and re-arms on the new thread, the same way the
loaded model survives.

The microphone picker leaves the STT dropdown; the loop reads the device
chosen in Settings > Voice, adopts a pin made in the old picker on first
load, and falls back to the default input when a pinned mic is unplugged.
Parallel synthesis moves behind a gear in the "Speak with" header and
gets a row in Settings > Voice. Exported voices show their name instead
of a full filesystem path (loraOptionLabel). Opening voice seeds the last
used or default voice, since null no longer means "browser".

Header order is listen, speak, speaker name. The idle orb uses theme
tokens (--voice-orb-idle-*) in light and dark rather than a fixed grey;
the overlay fades in 200ms and stops animating while minimized. The two
STT sidecars spawn with the same hidden-window kwargs as llama-server so
whisper-server and the MTMD server no longer open console windows under
the desktop shell.
# Conflicts:
#	studio/backend/core/inference/llama_cpp.py
#	studio/frontend/src/components/assistant-ui/thread.tsx
main's ui-font-size-scales-spacing test rejects hand-set px lengths above a
hairline. Swap the voice and STT pickers' widths, heights and dots, and the
chat header's 34px rows, onto the scaled spacing steps. The mic icon in the
composer uses the calc() spelling the icon rules match.
danielhanchen and others added 23 commits November 14, 2026 16:21
… unmounted engine's mic retries go stale

[skip ci]
…oad checks its owner under the sidecar lock

[skip ci]
…tinuation holds the reply; speech waits for the current pick's slot
…the CPU, one voice load per reply

- The dictation mic was wrapped in a div, so the 22rem composer rule that shrinks
  '.aui-composer-action-wrapper > button' no longer reached it. Render it conditionally instead.
- Start PulseVAD on the CPU: nothing frees the detector for training or chat, so on the GPU it
  held memory until Studio exited.
- A failing voice load was retried and toasted once per sentence; once per reply now.
- Turning Voice off while the mic was starting showed a false microphone error.

[skip ci]
… a speech request

A voice ejected from Loaded models kept voiceSlotLoaded set, so the next reply named an unloaded
voice; with switch model by request on and multi-model off, that loaded it as the chat model.

[skip ci]
…r reply

A voice ejected while queued clips played was still named by the reply's later sentences.
danielhanchen added a commit that referenced this pull request Nov 15, 2026
…relative imports (#17853)

## Summary


`tests/test_grpo_prefix_grouper_capability.py::test_pre_patch_gate_applies_only_on_marked_modules`
has failed in `Repo tests (CPU, rest)` on `main` since #17830 ("keep
layer gradient checkpointing on transformers 5.23+"). Seen on the
staging run of #12384, base `57d9d1de`:

```
unsloth/models/llama.py:3456: in _gated_method
    from ._block_compile import _checkpointing, _is_hf_checkpoint_wrapper
E   KeyError: "'__name__' not in globals"
```

#17830 is correct: `_gated_method` now re-applies transformers' layer
checkpoint wrapper. The test's `_top_level` helper pulls functions out
of `llama.py` with `ast` and execs them in a bare namespace, to avoid
importing `unsloth` (GPU init). A relative import has no package to
resolve against in that namespace.

## Change (test only)

`_top_level` now gives the namespace a `__name__` and `__package__`
under a stand-in package (`_unsloth_models_under_test`), registered once
with `__path__ = [unsloth/models]`. A relative import inside an
extracted function then loads the real sibling file (`_block_compile.py`
here) as `_unsloth_models_under_test._block_compile`. It does not run
`unsloth/models/__init__.py`, so the harness still avoids the GPU stack,
and the test exercises the shipped `_checkpointing` /
`_is_hf_checkpoint_wrapper` rather than stubs.

## Verification

| | `tests/test_grpo_prefix_grouper_capability.py` |
|---|---|
| main (`57d9d1de`) | 1 failed, 19 passed |
| this branch | 20 passed |
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 15, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Picked this up for #17822 (a user asking for a hands-free spoken back and forth). I merged current main into the branch and pushed a few fixes on top.

Fixes

  • 9bbf4abd8: The dictation mic was wrapped in a div, so the narrow-composer rule (.aui-composer-action-wrapper > button, 22rem) stopped shrinking it with voice off. It is rendered conditionally again. PulseVAD now starts on the CPU: nothing frees the detector for training or chat, so on the GPU it held memory until Studio exited. A failing voice load is retried and toasted once per reply instead of once per sentence. Turning Voice off while the mic is starting no longer shows a false microphone error.
  • 1f3fbcfba, a062df050, f34f3bf53: A voice ejected from Loaded models (or switched in the picker mid-check) kept voiceSlotLoaded set, so the next sentence named a voice that was not loaded. With "switch model by request" on and multi-model off, that loaded the voice as the chat model. The slot is now rechecked before every sentence, and a check for a voice the user has switched away from leaves the slot not ready.
  • 907eb4bbc: The detector's debug dump writes with encoding = "utf-8" (the text I/O gate in Backend CI).
  • 8a601e704: Comment trim, comments only.

End to end on a real install (CPU only, no torch)
Studio built from this branch at 1f3fbcfba, Chromium with a scripted microphone that says "What is the capital of France? Answer in one short sentence." once, gemma-3-270m GGUF for chat, Parakeet-TDT-0.6B-v3 for STT, Kokoro-82M for speech, PulseVAD for the detector. The later commits touch only the slot recheck, the slot owner and the debug dump encoding.

t (s) request result
11 POST /audio/vad/detect 200, speech found
13 POST /audio/transcribe/raw 200, "What is the capital of France? Answer in one short sentence."
14 POST /inference/chat-runs 202, sent with no click
217 POST /audio/generate (Kokoro) 200, reply "The capital of France is Paris." spoken
241 Voice off: POST /audio/vad/unload, POST /inference/unload 200, 200; /audio/vad/status reports no detector loaded

The chat model stayed loaded the whole time. The reply took a few minutes only because the host was heavily loaded.

Checks

  • Frontend: node --test tests/voice-*.test.ts 123 pass, tsc -p tsconfig.app.json clean. New tests cover the mic placement, the per-sentence recheck and the switched-voice case; each fails without its fix.
  • Backend: the voice, VAD, multi-model, audio.cpp catalog/update, account isolation and text I/O encoding suites pass (1790), including a new test that the detector starts on the CPU.
  • Studio regression switchboard at 907eb4bbc against the merge base: NO_REGRESSION (69 same, 2 failing on both sides already, 1 flaky that did not reproduce).
  • Staging CI at 907eb4bbc: everything this PR touches is green. The four red jobs fail on main without this PR: tests/test_grpo_prefix_grouper_capability.py::test_pre_patch_gate_applies_only_on_marked_modules (fails on main 57d9d1ded locally) and the zoo DeepSeek-V4.1 test_native_loop_backend_casts_dense_experts_like_the_native_forward exact-equality check in the three Core zoo legs.

Before / after

Chat + menu, before and after: Voice is the only new item

The voice orb during the run above: warming up, writing the answer, speaking, listening again

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reddit issue] Multi-speaker TTS and Live turn-based conversation

4 participants