From ac04c674a60d2aacd3745b003fe07678e36974de Mon Sep 17 00:00:00 2001 From: Anais Saraiva Date: Thu, 24 Sep 2026 11:42:53 +0200 Subject: [PATCH] . --- frontend/src/components/AdminCenter.tsx | 22 ++++++++++++++---- frontend/src/components/dialogs.tsx | 30 +++++++++++++++++-------- frontend/src/lib/i18n.ts | 12 ++++++++++ frontend/src/lib/voice.ts | 3 +++ prompt_v2 | 3 +++ 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/AdminCenter.tsx b/frontend/src/components/AdminCenter.tsx index a248f56..4c89b7b 100644 --- a/frontend/src/components/AdminCenter.tsx +++ b/frontend/src/components/AdminCenter.tsx @@ -14,6 +14,7 @@ import { Button, CopyButton, Field, FlowerMark, Input, LoadingScreen, Picker, Sp import { cn } from "../lib/cn.ts"; import { msUntilNextSolarSwitch, resolveThemeDark } from "../lib/solarTheme.ts"; import { useT, type StringKey } from "../lib/i18n.ts"; +import { OPENAI_STATIC_VOICES } from "../lib/voice.ts"; type Tab = "accounts" | "access" | "reports" | "models" | "stats" | "features" | "mail"; @@ -349,6 +350,8 @@ function VoicePreviewsCard() { const [busy, setBusy] = useState(false); const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null); const [serverVoices, setServerVoices] = useState<{ id: string; name: string }[]>([]); + const [ttsProvider, setTtsProvider] = useState(null); + const [ttsAvailable, setTtsAvailable] = useState(false); useEffect(() => { api.adminGetSettings() @@ -357,7 +360,13 @@ function VoicePreviewsCard() { setLoaded(true); }) .catch(() => setLoaded(true)); - api.ttsInfo().then((r) => setServerVoices(r.voices)).catch(() => {}); + api.ttsInfo() + .then((r) => { + setServerVoices(r.voices); + setTtsProvider(r.provider); + setTtsAvailable(r.available); + }) + .catch(() => {}); }, []); async function save(next: VoicePreview[]) { @@ -454,8 +463,8 @@ function VoicePreviewsCard() { - - {serverVoices.length > 0 ? ( + + {serverVoices.length > 0 || ttsProvider !== "elevenlabs" ? ( ({ value: v.id, label: v.name }))]} + options={[ + { value: "", label: t("vfeat.voicePh") }, + ...(serverVoices.length > 0 + ? serverVoices.map((v) => ({ value: v.id, label: v.name })) + : OPENAI_STATIC_VOICES.map((v) => ({ value: v, label: v }))), + ]} /> ) : ( {(prefs.engine !== "browser") && ( - ttsServer?.available ? ( - ttsServer.voices.length > 0 ? ( + <> + {!ttsServer?.available && ( +

{t("voice.noServer")}

+ )} + {ttsServer && ttsServer.voices.length > 0 ? ( ({ value: v.id, label: v.name }))]} /> - ) : ttsServer.provider === "elevenlabs" ? ( + ) : ttsServer?.provider === "elevenlabs" ? ( - ) : ( + ) : ttsServer?.provider === "piper" ? (

{t("voice.piperNote")}

- ) - ) : ( -

{t("voice.noServer")}

- ) + ) : ( + + update({ serverVoice: v || null })} + align="left" + options={[{ value: "", label: t("voice.defaultVoice") }, ...OPENAI_STATIC_VOICES.map((v) => ({ value: v, label: v }))]} + /> + + )} + )}