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 -1
View File
@@ -28,7 +28,10 @@ export function speakWithPiper(text, { language, voice = "", rate, volume = 1, i
if (current === job) current = null;
callback?.();
};
const timer = setTimeout(() => job.controller.abort(), PIPER_TIMEOUT_MS);
// Short calls (count-down) must be on time; a long line such as a heat call with every
// driver's name gets longer to be generated before the browser voice takes over.
const timeoutMs = PIPER_TIMEOUT_MS + Math.min(7500, Math.max(0, String(text || "").length - 40) * 60);
const timer = setTimeout(() => job.controller.abort(), timeoutMs);
fetch("/api/tts/speech", {
method: "POST",
headers: { "Content-Type": "application/json" },