Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: link the Read aloud TTS row to Audio and show the preview generate wait (#9093)
Michael Han2f80f11ccdfc
diff --git a/studio/backend/tests/test_metal_explicit_context_guard.py b/studio/backend/tests/test_metal_explicit_context_guard.pyindex 0440570a455..3474e9de2ef 100644--- a/studio/backend/tests/test_metal_explicit_context_guard.py+++ b/studio/backend/tests/test_metal_explicit_context_guard.py@@ -603,17 +603,13 @@ class TestAContextAboveTheModelsNativeLength:published = out["backend"].max_context_lengthassert published == loaded- def test_the_published_bound_never_runs_ahead_of_the_request(- self, tmp_path, monkeypatch- ):+ def test_the_published_bound_never_runs_ahead_of_the_request(self, tmp_path, monkeypatch):"""The fit is bounded by the request, so the bound may rise to the context thatloaded and no further. A bound past it would invite a context nothing priced."""out = self._above(tmp_path, monkeypatch, n_ctx = self._ASKED, kv_per_token = 1024)assert out["backend"].max_context_length <= self._ASKED- def test_a_refused_request_does_not_raise_the_published_bound(- self, tmp_path, monkeypatch- ):+ def test_a_refused_request_does_not_raise_the_published_bound(self, tmp_path, monkeypatch):"""Only an accepted ceiling is published. A refusal measured nothing it canstand behind at the request, so the bound stays where the cap left it."""with pytest.raises(RuntimeError, match = "unified"):diff --git a/studio/frontend/src/features/audio/audio-page.tsx b/studio/frontend/src/features/audio/audio-page.tsxindex 06d25b84427..e4594e74843 100644--- a/studio/frontend/src/features/audio/audio-page.tsx+++ b/studio/frontend/src/features/audio/audio-page.tsx@@ -1288,6 +1288,15 @@ export function AudioPage({ active = true }: { active?: boolean }) {const wanted = routeSearch.model;if (!wanted) {handledRouteModel.current = null;+ // A task with no model is a mode intent from Settings; without it the page keeps+ // whatever mode it was left in.+ const task = routeSearch.task;+ if (!task) return;+ const intended =+ task === "automatic-speech-recognition" ? "transcribe" : "speak";+ // Left in the URL when the switch is refused, so it retries once busy releases.+ if (intended !== mode && !transitionMode(intended)) return;+ void navigateSelf({ to: "/audio", search: {}, replace: true });return;}const key = `${wanted}|${routeSearch.quant ?? ""}|${routeSearch.ggufQuant ?? ""}|${routeSearch.task ?? ""}`;@@ -1310,12 +1319,14 @@ export function AudioPage({ active = true }: { active?: boolean }) {}, [active,busy,+ mode,routeSearch.model,routeSearch.quant,routeSearch.ggufQuant,routeSearch.task,handleModelSelect,navigateSelf,+ transitionMode,]);// --- Speak --------------------------------------------------------------diff --git a/studio/frontend/src/features/settings/tabs/voice-tab.tsx b/studio/frontend/src/features/settings/tabs/voice-tab.tsxindex 497030c2bf8..6c611dbedeb 100644--- a/studio/frontend/src/features/settings/tabs/voice-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/voice-tab.tsx@@ -44,8 +44,13 @@ import { isTauri } from "@/lib/api-base";import { ChevronDownStandardIcon } from "@/lib/chevron-icons";import { MicIcon } from "@/lib/mic-icon";import { toast } from "@/lib/toast";-import { Search01Icon, VolumeHighIcon } from "@hugeicons/core-free-icons";+import {+ AudioWave01Icon,+ Search01Icon,+ VolumeHighIcon,+} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";+import { useNavigate } from "@tanstack/react-router";import { SquareIcon } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { resetMicrophonePermission } from "../api/microphone-permission";@@ -57,6 +62,7 @@ import {isTrackingSttDownload,trackSttDownload,} from "../lib/stt-download-mirror";+import { useSettingsDialogStore } from "../stores/settings-dialog-store";import {MTMD_STT_MODELS,RECOMMENDED_STT_MODELS,@@ -415,6 +421,7 @@ export function VoiceTab() {const ttsVolume = useVoiceSettingsStore((s) => s.ttsVolume);const setTtsVolume = useVoiceSettingsStore((s) => s.setTtsVolume);+ const navigate = useNavigate();const { devices, hasLabels, requestAccess } = useAudioInputDevices();const rawVoices = useSystemVoices();const voices = useMemo(@@ -422,6 +429,9 @@ export function VoiceTab() {[rawVoices, ttsVoiceURI, dictationLanguage],);const [previewing, setPreviewing] = useState(false);+ // A studio preview generates the whole clip before it plays; separate from `previewing`+ // so the wait shows as work.+ const [preparingPreview, setPreparingPreview] = useState(false);const [subpage, setSubpage] = useState<"main" | "recents" | "dictionary">("main",);@@ -744,6 +754,8 @@ export function VoiceTab() {const markPreviewing = useCallback((value: boolean) => {previewingRef.current = value;setPreviewing(value);+ // Every exit from the generate await clears previewing, so clear both here.+ if (!value) setPreparingPreview(false);}, []);const releasePreviewAudio = useCallback(() => {@@ -779,12 +791,14 @@ export function VoiceTab() {previewAbortRef.current = controller;ownsSystemPreviewRef.current = false;markPreviewing(true);+ setPreparingPreview(true);try {const url = await generateStudioTtsAudio(TTS_PREVIEW_TEXT,controller.signal,);if (controller.signal.aborted) return;+ setPreparingPreview(false);const audio = new Audio(url);audio.playbackRate = ttsRate;audio.volume = ttsVolume;@@ -1223,7 +1237,27 @@ export function VoiceTab() {<SettingsRowlabel={t("settings.voice.readAloud.modelLabel")}description={t("settings.voice.readAloud.modelDescription")}- />+ >+ {/* The row named the model selector but offered no way to reach it. */}+ <Button+ variant="outline"+ size="sm"+ onClick={() => {+ useSettingsDialogStore.getState().closeDialog();+ // Audio keeps the mode it was left in, so name the TTS task.+ void navigate({+ to: "/audio",+ search: { task: "text-to-speech" },+ });+ }}+ >+ <HugeiconsIcon+ icon={AudioWave01Icon}+ className="mr-1.5 size-3.5"+ />+ {t("settings.voice.readAloud.openAudioAction")}+ </Button>+ </SettingsRow>) : (<SettingsRowlabel={t("settings.voice.readAloud.voiceLabel")}@@ -1307,7 +1341,15 @@ export function VoiceTab() {size="sm"onClick={() => void previewTts()}>- {previewing ? (+ {preparingPreview ? (+ <>+ <Spinner+ className="mr-1.5 size-3.5"+ label={t("settings.voice.readAloud.preparingAction")}+ />+ {t("settings.voice.readAloud.preparingAction")}+ </>+ ) : previewing ? (<><SquareIcon className="mr-1.5 size-3 animate-pulse fill-current text-destructive" />{t("settings.voice.readAloud.stopAction")}diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex cf19ebe5b74..a34183b6655 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -358,6 +358,7 @@ export const ar = {modelLabel: "نموذج TTS",modelDescription:"حمّل نموذجًا صوتيًا من محدّد النماذج (مثل Orpheus TTS)",+ openAudioAction: "فتح الصوت",voiceLabel: "الصوت",voiceDescription: "أفضل الأصوات على هذا الجهاز",speedLabel: "السرعة",@@ -367,6 +368,7 @@ export const ar = {previewDescription: "تشغيل عيّنة قصيرة",previewFailed: "فشلت معاينة تحويل النص إلى كلام",previewAction: "معاينة",+ preparingAction: "جارٍ الإنشاء…",stopAction: "إيقاف",ttsLabel: "تحويل النص إلى كلام",notSupported: "غير مدعوم في هذا المتصفح",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex d2d7f4fde22..2c5b3cd5cd5 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -369,6 +369,7 @@ export const de = {modelLabel: "TTS-Modell",modelDescription:"Laden Sie ein Audiomodell über die Modellauswahl (z. B. Orpheus TTS)",+ openAudioAction: "Audio öffnen",voiceLabel: "Stimme",voiceDescription: "Beste Stimmen auf diesem Gerät",speedLabel: "Geschwindigkeit",@@ -378,6 +379,7 @@ export const de = {previewDescription: "Eine kurze Hörprobe abspielen",previewFailed: "Die TTS-Vorschau ist fehlgeschlagen",previewAction: "Anhören",+ preparingAction: "Wird erzeugt…",stopAction: "Stopp",ttsLabel: "Sprachausgabe",notSupported: "In diesem Browser nicht unterstützt",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 5b7814c9d55..a7104afe193 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -359,6 +359,7 @@ export const en = {modelLabel: "TTS model",modelDescription:"Load an audio model from the model selector (e.g. Orpheus TTS)",+ openAudioAction: "Open Audio",voiceLabel: "Voice",voiceDescription: "Best voices on this device",speedLabel: "Speed",@@ -368,6 +369,7 @@ export const en = {previewDescription: "Play a short sample",previewFailed: "TTS preview failed",previewAction: "Preview",+ preparingAction: "Generating…",stopAction: "Stop",ttsLabel: "Text to speech",notSupported: "Not supported in this browser",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 5fe5c481c33..aa4f1701e8f 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -366,6 +366,7 @@ export const es = {modelLabel: "Modelo de TTS",modelDescription:"Carga un modelo de audio desde el selector de modelos (por ejemplo, Orpheus TTS)",+ openAudioAction: "Abrir Audio",voiceLabel: "Voz",voiceDescription: "Las mejores voces de este dispositivo",speedLabel: "Velocidad",@@ -374,6 +375,7 @@ export const es = {previewLabel: "Escuchar la voz",previewDescription: "Reproducir una muestra corta",previewAction: "Escuchar",+ preparingAction: "Generando…",previewFailed: "No se pudo reproducir la muestra de TTS",stopAction: "Detener",ttsLabel: "Texto a voz",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 5225a111587..956ceaac266 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -368,6 +368,7 @@ export const fr = {modelLabel: "Modèle TTS",modelDescription:"Chargez un modèle audio depuis le sélecteur de modèles (par exemple Orpheus TTS)",+ openAudioAction: "Ouvrir Audio",voiceLabel: "Voix",voiceDescription: "Meilleures voix sur cet appareil",speedLabel: "Vitesse",@@ -377,6 +378,7 @@ export const fr = {previewDescription: "Lire un court extrait",previewFailed: "Échec de l’aperçu de la synthèse vocale",previewAction: "Écouter",+ preparingAction: "Génération…",stopAction: "Arrêter",ttsLabel: "Synthèse vocale",notSupported: "Indisponible dans ce navigateur",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex c607150c7bb..4b0aca87f9b 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -363,6 +363,7 @@ export const hi = {modelLabel: "TTS मॉडल",modelDescription:"मॉडल सिलेक्टर से एक ऑडियो मॉडल लोड करें (जैसे Orpheus TTS)",+ openAudioAction: "ऑडियो खोलें",voiceLabel: "आवाज़",voiceDescription: "इस डिवाइस पर सबसे अच्छी आवाज़ें",speedLabel: "गति",@@ -372,6 +373,7 @@ export const hi = {previewDescription: "एक छोटा नमूना चलाएँ",previewFailed: "TTS पूर्वावलोकन विफल रहा",previewAction: "सुनें",+ preparingAction: "बना रहे हैं…",stopAction: "रोकें",ttsLabel: "टेक्स्ट-टू-स्पीच",notSupported: "इस ब्राउज़र में समर्थित नहीं है",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 2a3c643c950..cb5f645a8ba 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -332,6 +332,7 @@ export const it = {modelLabel: "Modello TTS",modelDescription:"Carica un modello audio dal selettore dei modelli (es. Orpheus TTS)",+ openAudioAction: "Apri Audio",voiceLabel: "Voce",voiceDescription: "Le migliori voci disponibili su questo dispositivo",speedLabel: "Velocità",@@ -340,6 +341,7 @@ export const it = {previewLabel: "Ascolta la voce",previewDescription: "Riproduci un breve campione",previewAction: "Ascolta",+ preparingAction: "Generazione…",previewFailed: "Impossibile riprodurre l'anteprima TTS",stopAction: "Interrompi",ttsLabel: "Sintesi vocale",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex f722eaca425..1528c9aa227 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -362,6 +362,7 @@ export const ja = {modelLabel: "TTS モデル",modelDescription:"モデルセレクターから音声モデルを読み込んでください (例: Orpheus TTS)",+ openAudioAction: "音声を開く",voiceLabel: "音声",voiceDescription: "このデバイスで最適な音声",speedLabel: "速度",@@ -370,6 +371,7 @@ export const ja = {previewLabel: "音声を試聴",previewDescription: "短いサンプルを再生します",previewAction: "試聴",+ preparingAction: "生成中…",previewFailed: "TTS のプレビューに失敗しました",stopAction: "停止",ttsLabel: "音声合成",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex c701c423727..86c6c651af9 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -358,6 +358,7 @@ export const ko = {modelLabel: "TTS 모델",modelDescription:"모델 선택기에서 오디오 모델을 로드하세요(예: Orpheus TTS)",+ openAudioAction: "오디오 열기",voiceLabel: "음성",voiceDescription: "이 기기에서 가장 좋은 음성",speedLabel: "속도",@@ -366,6 +367,7 @@ export const ko = {previewLabel: "음성 미리 듣기",previewDescription: "짧은 샘플을 재생합니다",previewAction: "미리 듣기",+ preparingAction: "생성 중…",previewFailed: "TTS 미리 듣기에 실패했습니다",stopAction: "정지",ttsLabel: "텍스트 음성 변환",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 59aff338953..29b99693b48 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -364,6 +364,7 @@ export const ptBR = {modelLabel: "Modelo de TTS",modelDescription:"Carregue um modelo de áudio pelo seletor de modelos (por exemplo, Orpheus TTS)",+ openAudioAction: "Abrir Áudio",voiceLabel: "Voz",voiceDescription: "As melhores vozes deste dispositivo",speedLabel: "Velocidade",@@ -372,6 +373,7 @@ export const ptBR = {previewLabel: "Ouvir a voz",previewDescription: "Reproduz uma amostra curta",previewAction: "Ouvir",+ preparingAction: "Gerando…",previewFailed: "Não foi possível reproduzir a prévia de TTS",stopAction: "Parar",ttsLabel: "Conversão de texto em fala",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex e487e34f121..45449fb0246 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -363,6 +363,7 @@ export const ru = {modelLabel: "Модель TTS",modelDescription:"Загрузите аудиомодель из списка моделей (например, Orpheus TTS)",+ openAudioAction: "Открыть Аудио",voiceLabel: "Голос",voiceDescription: "Лучшие голоса на этом устройстве",speedLabel: "Скорость",@@ -372,6 +373,7 @@ export const ru = {previewDescription: "Воспроизвести короткий пример",previewFailed: "Не удалось воспроизвести пример синтеза речи",previewAction: "Прослушать",+ preparingAction: "Генерация…",stopAction: "Остановить",ttsLabel: "Синтез речи",notSupported: "Не поддерживается в этом браузере",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex 0ce553f4020..afa7fb21fbe 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -350,6 +350,7 @@ export const zhCN = {engineStudio: "加载 TTS 模型",modelLabel: "TTS 模型",modelDescription: "从模型选择器加载音频模型(例如 Orpheus TTS)",+ openAudioAction: "打开音频",voiceLabel: "音色",voiceDescription: "此设备上效果最好的音色",speedLabel: "语速",@@ -358,6 +359,7 @@ export const zhCN = {previewLabel: "试听音色",previewDescription: "播放一段简短示例",previewAction: "试听",+ preparingAction: "生成中…",previewFailed: "TTS 试听失败",stopAction: "停止",ttsLabel: "文字转语音",diff --git a/studio/frontend/tests/read-aloud-tts-model-row.test.ts b/studio/frontend/tests/read-aloud-tts-model-row.test.tsnew file mode 100644index 00000000000..e263404e995--- /dev/null+++ b/studio/frontend/tests/read-aloud-tts-model-row.test.ts@@ -0,0 +1,70 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";++const source = readFileSync(+ new URL("../src/features/settings/tabs/voice-tab.tsx", import.meta.url),+ "utf8",+);+const en = readFileSync(+ new URL("../src/i18n/locales/en.ts", import.meta.url),+ "utf8",+);+const audioSource = readFileSync(+ new URL("../src/features/audio/audio-page.tsx", import.meta.url),+ "utf8",+);++test("the studio TTS row offers the Audio page it tells the user to use", () => {+ // Settings is a modal, so it must close or Audio opens behind it.+ assert.match(+ source,+ /label=\{t\("settings\.voice\.readAloud\.modelLabel"\)\}[\s\S]*?useSettingsDialogStore\.getState\(\)\.closeDialog\(\);[\s\S]{0,200}?void navigate\(\{\s*to: "\/audio",/,+ );+ assert.match(source, /t\("settings\.voice\.readAloud\.openAudioAction"\)/);+ assert.match(en, /openAudioAction: "Open Audio",/);+});++test("the row lands on the TTS selector, not the mode Audio was left in", () => {+ // AudioPage stays mounted and keeps its `mode`, so plain /audio can show the wrong selector.+ assert.match(+ source,+ /to: "\/audio",\s*search: \{ task: "text-to-speech" \},/,+ );+ // Audio ignored a task without a model, so the intent needs handling at the other end.+ assert.match(+ audioSource,+ /const task = routeSearch\.task;\s*if \(!task\) return;\s*const intended =\s*task === "automatic-speech-recognition" \? "transcribe" : "speak";/,+ );+ // A refused switch keeps the parameter, so the retry rides the effect's busy dep.+ assert.match(+ audioSource,+ /if \(intended !== mode && !transitionMode\(intended\)\) return;\s*void navigateSelf\(\{ to: "\/audio", search: \{\}, replace: true \}\);/,+ );+});++test("a studio preview shows the generate wait instead of an idle button", () => {+ // Stop during the generate wait read as idle, and extra clicks orphaned requests.+ assert.match(+ source,+ /markPreviewing\(true\);\s*setPreparingPreview\(true\);\s*try \{\s*const url = await generateStudioTtsAudio\(/,+ );+ assert.match(+ source,+ /if \(controller\.signal\.aborted\) return;\s*setPreparingPreview\(false\);/,+ );+ // Every other exit goes through markPreviewing, so clearing there covers them all.+ assert.match(+ source,+ /previewingRef\.current = value;\s*setPreviewing\(value\);[\s\S]*?if \(!value\) setPreparingPreview\(false\);/,+ );+ // Preparing outranks previewing: both are true during the wait.+ assert.match(+ source,+ /\{preparingPreview \? \([\s\S]*?<Spinner[\s\S]*?preparingAction"\)\}[\s\S]*?\) : previewing \? \(/,+ );+ assert.match(en, /preparingAction: "Generating…",/);+});