dev
This commit is contained in:
parent
8caa75e388
commit
90677847f1
@ -88,19 +88,26 @@ function playSpeech(text) {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
text: text,
|
text: text,
|
||||||
}),
|
}),
|
||||||
}).then(
|
})
|
||||||
response => {
|
.then(response => {
|
||||||
audio = document.createElement('audio');
|
if (!response.ok) {
|
||||||
audio.src = response.blob();
|
throw new Error('Ошибка сети: ' + response.statusText);
|
||||||
audio.play().catch(error => {
|
}
|
||||||
console.error('Ошибка при воспроизведении:', error);
|
return response.blob();
|
||||||
});
|
})
|
||||||
|
.then(response => {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const audio = new Audio(url);
|
||||||
|
|
||||||
audio.addEventListener('ended', () => {
|
audio.play().catch(error => {
|
||||||
audio.pause();
|
console.error('Ошибка при воспроизведении:', error);
|
||||||
audio.remove();
|
});
|
||||||
console.log('Аудио закончилось и временный URL удален.');
|
|
||||||
});
|
audio.addEventListener('ended', () => {
|
||||||
|
audio.pause();
|
||||||
|
audio.remove();
|
||||||
|
console.log('Аудио закончилось и временный URL удален.');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user