Spaces:
Sleeping
Sleeping
document.getElementById('submit-audio').addEventListener('click', async () => { | |
const audioInput = document.getElementById('audio-input'); | |
if (audioInput.files.length === 0) { | |
alert('Please select an audio file.'); | |
return; | |
} | |
const formData = new FormData(); | |
formData.append('audio', audioInput.files[0]); | |
try { | |
const response = await fetch('/process_audio', { | |
method: 'POST', | |
body: formData | |
}); | |
const data = await response.json(); | |
document.querySelector('.response-text').textContent = data.response_text; | |
const audioElement = document.querySelector('.response-audio'); | |
audioElement.src = data.response_audio_url; | |
audioElement.style.display = 'block'; | |
} catch (error) { | |
console.error('Error:', error); | |
} | |
}); | |