Skip to content

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.

Studio: stop read aloud from waiting on a model catalog rescan (#16831)

oobabooga941722b700d0
diff --git a/studio/frontend/src/features/chat/adapters/studio-speech-synthesis-adapter.ts b/studio/frontend/src/features/chat/adapters/studio-speech-synthesis-adapter.ts
index 4422eaf1b5e..43c32a425ac 100644
--- a/studio/frontend/src/features/chat/adapters/studio-speech-synthesis-adapter.ts
+++ b/studio/frontend/src/features/chat/adapters/studio-speech-synthesis-adapter.ts
@@ -210,13 +210,14 @@ export function createConfiguredUtterance(
return utterance;
}
-/** Named because an unnamed request reaches the active (chat) model; null leaves it unnamed. */
+/** Named because an unnamed request reaches the active (chat) model; null leaves it unnamed.
+ * Lists loaded models only: /v1/models rescans every downloaded model once its cache expires. */
async function resolveReadAloudModel(
wantsClone: boolean,
signal?: AbortSignal,
): Promise<string | null> {
try {
- const res = await authFetch("/v1/models", { signal });
+ const res = await authFetch("/api/inference/loaded-models", { signal });
if (!res.ok) return null;
return loadedSpeechModelId(
audioModelsFromCatalog(await res.json()),
diff --git a/studio/frontend/tests/read-aloud-studio-voice.test.ts b/studio/frontend/tests/read-aloud-studio-voice.test.ts
index 6d9d64bbb9a..1bbc01ee566 100644
--- a/studio/frontend/tests/read-aloud-studio-voice.test.ts
+++ b/studio/frontend/tests/read-aloud-studio-voice.test.ts
@@ -34,9 +34,10 @@ const MAX_TOKENS = 1234;
function load(
voiceId: string,
reply: Reply = { status: 200, body: { audio: { data: "UklGRg==" } } },
- // GET /v1/models: the listing, or an Error for a failed request.
+ // GET /api/inference/loaded-models: the listing, or an Error for a failed request.
models: unknown = { data: [] },
) {
+ const listed: string[] = [];
const posted: Record<string, unknown>[] = [];
const setVoiceIds: string[] = [];
const warnings: string[] = [];
@@ -48,7 +49,11 @@ function load(
{
"@/features/auth": {
authFetch: async (input: string, init?: { body?: string }) => {
- if (input === "/v1/models") {
+ if (!init?.body) {
+ listed.push(input);
+ if (input !== "/api/inference/loaded-models") {
+ throw new Error(`unexpected listing ${input}`);
+ }
if (models instanceof Error) throw models;
return { ok: true, status: 200, json: async () => models };
}
@@ -92,7 +97,7 @@ function load(
},
},
);
- return { adapter, posted, setVoiceIds, warnings };
+ return { adapter, listed, posted, setVoiceIds, warnings };
}
test("read aloud keeps its clip out of history and speaks in the model's voice by default", async () => {
@@ -214,6 +219,22 @@ test("read aloud names the loaded speech model, so one beside the chat model ans
assert.equal(posted[0].model, KOKORO);
});
+test("read aloud lists only loaded models, never the full catalog", async () => {
+ const { adapter, listed, posted } = load("", undefined, {
+ data: [
+ {
+ id: KOKORO,
+ loaded: true,
+ task: "text-to-speech",
+ audio_workflows: ["speak"],
+ },
+ ],
+ });
+ await adapter.generateStudioTtsAudio("hello");
+ assert.deepEqual(listed, ["/api/inference/loaded-models"]);
+ assert.equal(posted[0].model, KOKORO);
+});
+
test("a saved voice prefers a loaded model that can clone", async () => {
const { adapter, posted } = load("8f2c", undefined, {
data: [
diff --git a/studio/frontend/tests/tts-custom-connections-disabled.test.ts b/studio/frontend/tests/tts-custom-connections-disabled.test.ts
index af42096d3f1..b1f109177d7 100644
--- a/studio/frontend/tests/tts-custom-connections-disabled.test.ts
+++ b/studio/frontend/tests/tts-custom-connections-disabled.test.ts
@@ -76,7 +76,7 @@ function load(
options?: { beforeRetry?: () => void },
) => {
// The Unsloth Studio engine first lists the loaded models; it is not a speech request.
- if (input === "/v1/models") {
+ if (input === "/api/inference/loaded-models") {
return { ok: true, json: async () => ({ data: [] }) };
}
if (beforeAuthenticatedRetry) {