diff --git a/internal/model/widget-templates.go b/internal/model/widget-templates.go index b7ffa95..fd137bb 100644 --- a/internal/model/widget-templates.go +++ b/internal/model/widget-templates.go @@ -69,14 +69,25 @@ function addText(text) { } async function playAudio(audioUrl) { - audio = document.createElement('audio'); - audio.src = audioUrl; - audio.controls = false; - contentDiv.appendChild(audio); - audio.play() - await delay(5000); - audio.pause(); - audio.remove(); + fetch(audioUrl) + .then(response => { + if (!response.ok) { + throw new Error('Ошибка сети: ' + response.statusText); + } + return response.blob(); + }) + .then(blob => { + const url = URL.createObjectURL(blob); + const audio = new Audio(url); + + audio.play().catch(error => { + console.error('Ошибка при воспроизведении:', error); + }); + + await delay(5000); + audio.pause(); + audio.remove(); + ) } function playSpeech(text) {