dev
This commit is contained in:
parent
1ffffc813c
commit
ab52c5227e
@ -77,13 +77,25 @@ async function playAudio(audioUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function playSpeech(text) {
|
function playSpeech(text) {
|
||||||
const audio = new Audio(ttsUrl + '/generate', {
|
audioUrl = fetch(ttsUrl + '/generate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
text: text,
|
text: text,
|
||||||
}),
|
}),
|
||||||
});
|
}).then(
|
||||||
audio.play()
|
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) {
|
function delay(ms) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user