diff --git a/internal/model/widget-templates.go b/internal/model/widget-templates.go index 3c68ad0..d110dd2 100644 --- a/internal/model/widget-templates.go +++ b/internal/model/widget-templates.go @@ -69,7 +69,10 @@ function addText(text) { } async function playAudio(audioUrl) { - const audio = new Audio(audioUrl); + audio = document.createElement('audio'); + audio.src = audioUrl; + audio.controls = false; + contentDiv.appendChild(audio); audio.play() await delay(5000); audio.pause(); @@ -87,14 +90,15 @@ function playSpeech(text) { }), }).then( response => { - const audioUrl = URL.createObjectURL(blob); - const audio = new Audio(audioUrl); + audio = document.createElement('audio'); + audio.src = audioUrl; audio.play().catch(error => { console.error('Ошибка при воспроизведении:', error); }); audio.addEventListener('ended', () => { - URL.revokeObjectURL(audioUrl); + audio.pause(); + audio.remove(); console.log('Аудио закончилось и временный URL удален.'); }); }