feat(tts): multi-voice switcher for EN & RU, Irina default voice, punctuation pause normalization and speed calibration

This commit is contained in:
2026-10-07 12:07:01 +03:00
parent 7893b353aa
commit 31e105b2c2
11 changed files with 486 additions and 61 deletions
+8 -2
View File
@@ -194,8 +194,14 @@ export function playAudio(url, speed = 1.0) {
}
}
export function playTextSpeech(text, lang = 'en', speed = 1.0) {
export function playTextSpeech(text, lang = 'en', speed = 1.0, voice = null) {
if (!text || !text.trim()) return null;
const url = `/api/tts?text=${encodeURIComponent(text.trim())}&lang=${lang}&speed=${speed}`;
const isRu = lang && lang.toLowerCase().startsWith('ru');
const savedVoice = isRu ? localStorage.getItem('notes_tts_voice_ru') : localStorage.getItem('notes_tts_voice_en');
const activeVoice = voice || savedVoice;
let url = `/api/tts?text=${encodeURIComponent(text.trim())}&lang=${lang}&speed=${speed}`;
if (activeVoice) {
url += `&voice=${encodeURIComponent(activeVoice)}`;
}
return playAudio(url, speed);
}