dev
This commit is contained in:
parent
1ffffc813c
commit
ab52c5227e
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user