fix(audio): longer Piper time for long calls, fallback voice matches the line's language (1.55.2)

This commit is contained in:
larssand committed 2026-11-03 09:16:11 +01:00
1 parent c3aafba327
commit 36fe1e3933
6 files changed
+21 -8

No files matched your search

+4 -2
View File
@@ -364,9 +364,11 @@ export function getSpeechVoicesHelper() {
export function selectSpeechVoice(voices, voiceUri, language) {
const items = Array.isArray(voices) ? voices : [];
const selected = items.find((voice) => voice.voiceURI === voiceUri);
if (selected) return selected;
const prefix = String(language || "").toLowerCase().split("-")[0];
// The chosen voice only when it speaks this line's language: a Swedish voice must not read
// an English call (and the other way round).
const selected = items.find((voice) => voice.voiceURI === voiceUri);
if (selected && (!prefix || String(selected.lang || "").toLowerCase().startsWith(prefix))) return selected;
return items.find((voice) => String(voice.lang || "").toLowerCase().startsWith(prefix) && voice.localService !== false)
|| items.find((voice) => String(voice.lang || "").toLowerCase().startsWith(prefix))
|| null;