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: send the TTS language to Supertonic and add a Speak language picker (#14511)
Daniel Han32491ae49859
diff --git a/studio/backend/core/inference/audio_cpp_backend.py b/studio/backend/core/inference/audio_cpp_backend.pyindex 503e67fb71e..148f25e454f 100644--- a/studio/backend/core/inference/audio_cpp_backend.py+++ b/studio/backend/core/inference/audio_cpp_backend.py@@ -204,9 +204,37 @@ def _reread_after_download(model: AudioCppModel, hf_token: Optional[str]) -> Audreturn fresh-# Strict specs that list no language option yet read the request's top-level language-# (audio.cpp extract_request_language: VoxCPM1 keeps Cantonese text Traditional with zh-HK).-_READS_TOP_LEVEL_LANGUAGE = frozenset({"voxcpm1", "audio8_tts"})+# Families that read the request's top-level language, not an option (audio.cpp extract_request_language:+# VoxCPM1 keeps Cantonese text Traditional with zh-HK; Supertonic generation_options_from_request).+_READS_TOP_LEVEL_LANGUAGE = frozenset({"voxcpm1", "audio8_tts", "supertonic"})+# Supertonic's tokenizer refuses anything but a bare ISO code (src/models/supertonic/tokenizer_text.cpp).+_LANGUAGE_CODE_FAMILIES = frozenset({"supertonic"})+# English names of the languages Supertonic reads (model_specs/supertonic.json).+_CODE_LANGUAGE_NAMES = {+ **_LANGUAGE_NAMES,+ "ar": "Arabic",+ "bg": "Bulgarian",+ "cs": "Czech",+ "da": "Danish",+ "el": "Greek",+ "et": "Estonian",+ "fi": "Finnish",+ "hi": "Hindi",+ "hr": "Croatian",+ "hu": "Hungarian",+ "id": "Indonesian",+ "lt": "Lithuanian",+ "lv": "Latvian",+ "nl": "Dutch",+ "pl": "Polish",+ "ro": "Romanian",+ "sk": "Slovak",+ "sl": "Slovenian",+ "sv": "Swedish",+ "tr": "Turkish",+ "uk": "Ukrainian",+ "vi": "Vietnamese",+}def model_info_fields(model: AudioCppModel) -> dict[str, Any]:@@ -344,6 +372,17 @@ def language_name(language: Optional[str]) -> Optional[str]:return None+def language_code(language: Optional[str]) -> Optional[str]:+ """``de-DE`` or ``German`` -> ``de``; None for Auto."""+ text = str(language or "").strip()+ if not text or text.lower() == "auto":+ return None+ for code, name in _CODE_LANGUAGE_NAMES.items():+ if name.lower() == text.lower():+ return code+ return text.lower().replace("_", "-").split("-", 1)[0]++def speech_input(model: AudioCppModel, text: str) -> str:"""VibeVoice refuses a script with no ``Speaker N:`` line."""if model.family == "vibevoice" and not _SPEAKER_LINE_RE.search(text or ""):@@ -973,11 +1012,20 @@ class AudioCppBackend:"audio.cpp: %s declares no instruction option; not sending the description",model.family,)+ top_language = Noneif language and str(language).strip():- if keys is None or "language" in keys:+ if model.family in _READS_TOP_LEVEL_LANGUAGE:+ top_language = (+ language_code(language)+ if model.family in _LANGUAGE_CODE_FAMILIES+ else str(language).strip()+ )+ elif keys is None or "language" in keys:requested["language"] = str(language).strip()else:logger.info("audio.cpp: %s does not declare language; not sending it", model.family)+ if top_language:+ body["language"] = top_languagemerged = {**default_options, **requested}if merged:body["options"] = merged@@ -993,16 +1041,17 @@ class AudioCppBackend:except AudioCppRequestError as exc:# 503 is a busy model, not a refused option. The server answers an option a family lacks with a# 4xx or a 500 depending on where the family validates it, so both count as a refusal here.- if not requested or exc.status == 503 or not 400 <= exc.status < 600:+ if not (requested or top_language) or exc.status == 503 or not 400 <= exc.status < 600:raise# The request's own description and language are hints; the package's defaults and the# user's options are not.logger.info("audio.cpp: %s rejected %s (%s); retrying without them",model.family,- sorted(requested),+ sorted([*requested, *(["language"] if top_language else [])]),exc.detail,)+ body.pop("language", None)if default_options:body["options"] = default_optionselse:diff --git a/studio/backend/tests/test_audio_cpp_models.py b/studio/backend/tests/test_audio_cpp_models.pyindex b288778cf31..db2e9aca103 100644--- a/studio/backend/tests/test_audio_cpp_models.py+++ b/studio/backend/tests/test_audio_cpp_models.py@@ -1542,6 +1542,45 @@ def test_audio_options_reach_the_request_validated():}+def test_supertonic_gets_the_language_top_level_as_a_code():+ # Supertonic reads only the top-level language (audio.cpp supertonic/session.cpp), never options.+ for keys in (None, frozenset({"speed", "num_inference_steps", "text_chunk_size", "seed"})):+ model = _speech_model("supertonic", request_keys = keys)+ b, srv = _backend_with(model, SPEECH_WAV)+ for given, sent in (+ ("de", "de"),+ (" de-DE ", "de"),+ ("German", "de"),+ ("hindi", "hi"),+ ("auto", None),+ ):+ b.generate_audio_response("Hallo", language = given)+ body = srv.calls[-1][1]+ assert body.get("language") == sent and "language" not in body.get("options", {})+ if keys is not None:+ assert audio_cpp_backend.model_info_fields(model)["audio_request_inputs"] == [+ "language"+ ]+++def test_a_refused_top_level_language_is_retried_without_it():+ from core.inference.audio_cpp_server import AudioCppRequestError++ b, srv = _backend_with(_speech_model("supertonic"), SPEECH_WAV)+ calls = []++ def post_json(path, payload, **kwargs):+ calls.append(json.loads(json.dumps(payload)))+ if len(calls) == 1:+ raise AudioCppRequestError(500, "invalid Supertonic language: xx")+ return SPEECH_WAV++ srv.post_json = post_json+ b.generate_audio_response("hi", language = "xx")+ assert calls[0]["language"] == "xx" and "language" not in calls[1]+ assert calls[1]["voice"] == "M1"++def test_speech_retry_keeps_package_defaults_and_user_options_and_covers_500():from core.inference.audio_cpp_server import AudioCppRequestErrordiff --git a/studio/frontend/src/features/audio/hooks/use-speech-generation.ts b/studio/frontend/src/features/audio/hooks/use-speech-generation.tsindex 809e6217326..fdf0fa6c9cd 100644--- a/studio/frontend/src/features/audio/hooks/use-speech-generation.ts+++ b/studio/frontend/src/features/audio/hooks/use-speech-generation.ts@@ -375,7 +375,10 @@ export function useSpeechGeneration({};const savedVoice =workflow === "speak" ? toolRequest.patch.inputs?.reference : undefined;- const language = audioLanguage.trim();+ // MOSS Local's language rides its Style panel; Supertonic's has its own.+ const language = (+ toolRequest.patch.language ?? (mossLocalGeneration ? audioLanguage : "")+ ).trim();saveLastPrompt(ttsDraftKey("prompt", workflow), prompt);if (savedVoice) {const voiceController = new AbortController();@@ -388,7 +391,7 @@ export function useSpeechGeneration({text,instructions:instructionsKind !== null && instructions ? instructions : null,- language: mossLocalGeneration && language ? language : null,+ language: language || null,inputs: { reference: savedVoice },options: requestOptions,speed: toolRequest.patch.speed ?? null,@@ -441,9 +444,7 @@ export function useSpeechGeneration({...(instructionsKind !== null && instructions? { audio_instructions: instructions }: {}),- ...(mossLocalGeneration && language- ? { audio_language: language }- : {}),+ ...(language ? { audio_language: language } : {}),...(Object.keys(requestOptions).length > 0? { audio_options: requestOptions }: {}),diff --git a/studio/frontend/src/features/audio/tools/panel-logic.ts b/studio/frontend/src/features/audio/tools/panel-logic.tsindex 8930a5ff7bf..7acca93ce54 100644--- a/studio/frontend/src/features/audio/tools/panel-logic.ts+++ b/studio/frontend/src/features/audio/tools/panel-logic.ts@@ -332,6 +332,26 @@ export const vibeVoiceDialogueLogic: AudioToolPanelLogic<null> = {toRequest: () => ({}),};+// audio.cpp model_specs/supertonic.json; anything else fails its tokenizer.+export const SUPERTONIC_LANGUAGES: readonly string[] = (+ "en ko ja ar bg cs da de el es et fi fr hi hr hu id it lt lv nl pl pt ro ru " ++ "sk sl sv tr uk vi"+).split(" ");++/** Language code, "" for the model's default (English). */+export const supertonicLanguageLogic: AudioToolPanelLogic<string> = {+ id: "supertonic-language",+ families: ["supertonic"],+ workflows: ["speak"],+ title: "Language",+ claims: [],+ initial: () => "",+ toRequest: (value) =>+ typeof value === "string" && SUPERTONIC_LANGUAGES.includes(value)+ ? { language: value }+ : {},+};+export const CLONE_PANEL_LOGIC = [qwen3TimbreLogic,indexTts2EmotionLogic,diff --git a/studio/frontend/src/features/audio/tools/speak-panels.tsx b/studio/frontend/src/features/audio/tools/speak-panels.tsxindex 29de52b5b17..e8231756191 100644--- a/studio/frontend/src/features/audio/tools/speak-panels.tsx+++ b/studio/frontend/src/features/audio/tools/speak-panels.tsx@@ -1,14 +1,23 @@// 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 {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { PillTabs } from "@/features/model-picker/components/model-selector/pill-tabs";import type { AudioOptionSpec } from "../audio-options";import { AudioOptionFields } from "../audio-options-fields";import { formatVibeVoiceScript } from "../clone-policy";import { VoicePicker } from "../components/voice-picker";import {+ SUPERTONIC_LANGUAGES,type SpeakVoiceValue,speakVoiceLogic,+ supertonicLanguageLogic,usesSavedVoice,vibeVoiceDialogueLogic,} from "./panel-logic";@@ -107,7 +116,48 @@ const vibeVoiceDialoguePanel: AudioToolPanel<null> = {},};+const LANGUAGE_NAMES = new Intl.DisplayNames(["en"], { type: "language" });+// Radix Select cannot hold an empty value.+const DEFAULT_LANGUAGE = "__default__";++const supertonicLanguagePanel: AudioToolPanel<string> = {+ ...supertonicLanguageLogic,+ Component: ({ value, onChange, disabled }) => (+ <div className="grid gap-1.5">+ <label+ className="text-ui-13 font-medium text-foreground"+ htmlFor="supertonic-language"+ >+ Language+ </label>+ <Select+ value={value || DEFAULT_LANGUAGE}+ onValueChange={(next) =>+ onChange(next === DEFAULT_LANGUAGE ? "" : next)+ }+ disabled={disabled}+ >+ <SelectTrigger id="supertonic-language" size="sm" className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={DEFAULT_LANGUAGE}>English (default)</SelectItem>+ {SUPERTONIC_LANGUAGES.filter((code) => code !== "en").map((code) => (+ <SelectItem key={code} value={code}>+ {LANGUAGE_NAMES.of(code) ?? code}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <p className="text-ui-11p5 leading-snug text-muted-foreground">+ The language of the text, so it is pronounced right.+ </p>+ </div>+ ),+};+export const SPEAK_TOOL_PANELS = [speakVoicePanel,vibeVoiceDialoguePanel,+ supertonicLanguagePanel,] as const;diff --git a/studio/frontend/tests/audio-clone-panels.test.ts b/studio/frontend/tests/audio-clone-panels.test.tsindex 67530757d64..4387f5729a0 100644--- a/studio/frontend/tests/audio-clone-panels.test.ts+++ b/studio/frontend/tests/audio-clone-panels.test.ts@@ -30,6 +30,7 @@ const {qwen3TimbreLogic,speakVoiceLogic,speakVoiceStored,+ supertonicLanguageLogic,vibeVoiceDialogueLogic,voiceOptionName,} = await import("../src/features/audio/tools/panel-logic.ts");@@ -120,6 +121,36 @@ test("the Voice panel shows on Speak for models that clone or declare a voice",);});+test("Supertonic's Language panel shows on Speak and sends only a code it reads", () => {+ const supertonic = ctx({+ audioFamily: "supertonic",+ audioWorkflows: ["speak"],+ });+ assert.equal(+ panelApplies(supertonicLanguageLogic, "speak", supertonic),+ true,+ );+ assert.equal(+ panelApplies(+ supertonicLanguageLogic,+ "speak",+ ctx({ audioFamily: "kokoro_tts", audioWorkflows: ["speak"] }),+ ),+ false,+ );+ const request = (stored: unknown) =>+ collectToolRequest(+ [{ ...supertonicLanguageLogic, Component: () => null }],+ stored === undefined ? {} : { "supertonic-language": stored },+ { text: "Hallo" },+ supertonic,+ ).patch;+ assert.deepEqual(request("de"), { language: "de" });+ assert.deepEqual(request(""), {});+ assert.deepEqual(request(undefined), {});+ assert.deepEqual(request("German"), {});+});+test("collectToolRequest merges every panel's part and returns the first error", () => {const a = {id: "a",