This commit is contained in:
mm 2024-10-30 01:59:46 +05:00
parent 1ffffc813c
commit ab52c5227e

View File

@ -77,13 +77,25 @@ async function playAudio(audioUrl) {
}
function playSpeech(text) {
const audio = new Audio(ttsUrl + '/generate', {
audioUrl = fetch(ttsUrl + '/generate', {
method: 'POST',
body: JSON.stringify({
text: text,
}),
});
audio.play()
}).then(
response => {
const audioUrl = URL.createObjectURL(blob);
const audio = new Audio(audioUrl);
audio.play().catch(error => {
console.error('Ошибка при воспроизведении:', error);
});
audio.addEventListener('ended', () => {
URL.revokeObjectURL(audioUrl);
console.log('Аудио закончилось и временный URL удален.');
});
}
)
}
function delay(ms) {