fix(audio): generate count-down calls ahead of time with Piper so no number is skipped (1.65.3)

This commit is contained in:
larssand committed 2026-11-05 19:33:10 +01:00
1 parent 62ec97c9e9
commit 13f32fc0d6
8 files changed
+53 -8

No files matched your search

+14 -1
View File
@@ -1,6 +1,6 @@
import { normalizeSeries } from "./series_logic.js";
import { normalizeRaceDays } from "./day_schedule_logic.js";
import { speakWithPiper, isPiperSpeaking } from "./piper_speech.js";
import { speakWithPiper, isPiperSpeaking, prefetchPiperLines } from "./piper_speech.js";
export function createDefaultAmmcConfigHelper() {
return {
managedEnabled: false,
@@ -389,6 +389,19 @@ export function selectSpeechVoice(voices, voiceUri, language) {
|| null;
}
// The same voice, language and speed as speakTextHelper below, so the server's cache matches.
export function prefetchSpeechHelper(lines, { state }, options = {}) {
if (state.settings.ttsEngine !== "piper") return Promise.resolve();
return prefetchPiperLines(lines.filter((line) => line?.text).map((line) => {
const language = String(line.language || "").toLowerCase().startsWith("sv") ? "sv" : "en";
return {
text: line.text, language,
voice: language === "sv" ? state.settings.ttsVoiceSv : state.settings.ttsVoiceEn,
rate: Math.max(0.65, Math.min(1.35, Number(options.rate ?? state.settings.speechRate ?? 0.95) || 0.95)),
};
}));
}
export function speakTextHelper(text, { state, currentLanguage }, options = {}) {
if (!text) return false;
if (state.settings.ttsEngine === "piper" && !options.skipPiper) {