feat(audio): add downloadable extra Piper voices with accents

Adds Alma (sv), Alan, Northern English, Cori, Alba (British/Scottish)
and Joe, John, Norman (American) as optional voices downloaded one at
a time from Settings, with gender (measured pitch) and accent shown in
the voice lists. The standard install is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-09-30 21:58:08 +02:00
1 parent aaca5e8c63
commit ebd0f74f40
15 files changed
+186 -25

No files matched your search

+21 -1
View File
@@ -39,7 +39,11 @@ export async function mountTtsSettings(container, deps) {
const hasLanguage = (language) => voicesFor(language).length > 0;
// Complete = a male and a female voice installed for every language.
const complete = LANGUAGES.every((language) => ["male", "female"].every((gender) => voicesFor(language).some((voice) => voice.gender === gender)));
const voiceLabel = (voice) => (voice.gender ? `${voice.label} (${t(voice.gender === "male" ? "tts.gender_male" : "tts.gender_female")})` : voice.label);
const voiceLabel = (voice) => {
const details = [voice.gender ? t(voice.gender === "male" ? "tts.gender_male" : "tts.gender_female") : "", voice.accent ? t(`tts.accent_${voice.accent}`) : ""].filter(Boolean);
return details.length ? `${voice.label} (${details.join(", ")})` : voice.label;
};
const downloadable = status?.downloadable || [];
const voiceSelect = (language) => {
const chosen = state.settings[voiceSettingKey(language)] || "";
const automatic = voicesFor(language).find((voice) => voice.isDefault) || voicesFor(language)[0];
@@ -82,6 +86,16 @@ export async function mountTtsSettings(container, deps) {
${voiceSelect("en")}
</div>
<p class="error" id="ttsTestError" hidden></p>
${downloadable.length ? `
<h4 class="mt-16">${escapeHtml(t("tts.more_voices"))}</h4>
<p class="hint">${escapeHtml(t("tts.more_voices_hint"))}</p>
<div class="tts-download-list">
${downloadable.map((voice) => `
<div class="tts-download-row">
<span>${voice.language === "sv" ? "Svenska" : "English"} · <strong>${escapeHtml(voiceLabel(voice))}</strong></span>
<button class="btn btn-mini" type="button" data-tts-download="${escapeHtml(voice.name)}" ${busy ? "disabled" : ""}>${escapeHtml(install.running && install.voice === voice.name ? t("tts.downloading") : t("tts.download"))}</button>
</div>`).join("")}
</div>` : ""}
${install.running || install.log?.length ? `<pre class="log-box">${escapeHtml((install.log || []).join("\n"))}${install.error ? `\n${escapeHtml(install.error)}` : ""}</pre>` : ""}
${pregen.total ? `<p class="hint">${escapeHtml(t("tts.pregenerate_progress", { done: pregen.done, total: pregen.total, failed: pregen.failed }))}</p>` : ""}`;
@@ -93,6 +107,12 @@ export async function mountTtsSettings(container, deps) {
await fetch("/api/tts/install", { method: "POST" });
remount();
});
container.querySelectorAll("[data-tts-download]").forEach((button) => {
button.addEventListener("click", async () => {
await fetch("/api/tts/install", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ voice: button.dataset.ttsDownload }) });
remount();
});
});
container.querySelector("#ttsPregenerate").addEventListener("click", async () => {
await fetch("/api/tts/pregenerate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ items: await buildPregenerateItems(state) }) });
remount();