add custome voice

This commit is contained in:
larssand
2026-08-28 13:47:25 +02:00
parent fa3e5ee379
commit 34e55ff7f6
9 changed files with 31 additions and 7 deletions

View File

@@ -335,8 +335,8 @@ export function speakTextHelper(text, { state, currentLanguage }, options = {})
const utterance = new SpeechSynthesisUtterance(text);
const language = options.language || currentLanguage();
utterance.lang = String(language).toLowerCase().startsWith("sv") ? "sv-SE" : "en-US";
utterance.rate = Math.max(0.65, Math.min(1.35, Number(state.settings.speechRate || 0.95) || 0.95));
utterance.pitch = Math.max(0.7, Math.min(1.3, Number(state.settings.speechPitch || 1) || 1));
utterance.rate = Math.max(0.65, Math.min(1.35, Number(options.rate ?? state.settings.speechRate ?? 0.95) || 0.95));
utterance.pitch = Math.max(0.7, Math.min(1.3, Number(options.pitch ?? state.settings.speechPitch ?? 1) || 1));
utterance.volume = Math.max(0, Math.min(1, Number(options.volume ?? 1)));
if (typeof options.onEnd === "function") utterance.onend = options.onEnd;
if (typeof options.onError === "function") utterance.onerror = options.onError;