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