feat(tts): integrate autonomous Piper neural TTS with zero-latency pre-warming for words and context
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user