feat(tts): integrate autonomous Piper neural TTS with zero-latency pre-warming for words and context

This commit is contained in:
2026-10-07 10:40:02 +03:00
parent 915d2784a2
commit a6fb4349e9
12 changed files with 514 additions and 27 deletions
+10 -2
View File
@@ -3,7 +3,7 @@
// =======================================================================
import { api } from './api.js';
import { escapeHtml, showToast, openModal, closeModal } from './ui.js';
import { escapeHtml, showToast, openModal, closeModal, playAudio } from './ui.js';
export let allCards = [];
export let collectionsList = ['General', 'Разговорный', 'Работа & IT', 'Книги & Сериалы', 'Идиомы'];
@@ -163,6 +163,14 @@ export function initDictionary() {
}
});
if (audioPlayBtn) {
audioPlayBtn.addEventListener('click', () => {
if (!currentLookupData || !currentLookupData.term) return;
const url = currentLookupData.audio_url || `/api/tts?text=${encodeURIComponent(currentLookupData.term)}&lang=en`;
playAudio(url);
});
}
async function performLookup() {
const term = termInput.value.trim();
if (!term) return;
@@ -188,7 +196,7 @@ export function initDictionary() {
resPhonetic.textContent = data.phonetic || '';
resPhonetic.style.display = data.phonetic ? 'inline-block' : 'none';
resPos.textContent = data.part_of_speech || 'Phrase';
audioPlayBtn.classList.add('hidden');
if (audioPlayBtn) audioPlayBtn.classList.remove('hidden');
if (data.definition_en) {
resDefinition.textContent = data.definition_en;