30 lines
961 B
JavaScript
30 lines
961 B
JavaScript
const audioFileInput = document.getElementById('audioFileInput');
|
|
const transcriptionResult = document.getElementById('transcriptionResult');
|
|
|
|
audioFileInput.addEventListener('change', () => {
|
|
const audioFile = audioFileInput.files[0];
|
|
|
|
if (!audioFile) {
|
|
transcriptionResult.textContent = "Bitte wählen Sie eine Audiodatei aus.";
|
|
return;
|
|
}
|
|
|
|
// FormData erstellen, um die Datei an den Server zu senden
|
|
const formData = new FormData();
|
|
formData.append('audioFile', audioFile);
|
|
|
|
// HTTP POST-Anfrage an den Server senden
|
|
fetch('http://localhost:3000/upload', {
|
|
method: 'POST',
|
|
body: formData,
|
|
})
|
|
.then(response => response.text())
|
|
.then(result => {
|
|
transcriptionResult.textContent = result;
|
|
})
|
|
.catch(error => {
|
|
transcriptionResult.textContent = "Fehler beim Transkribieren der Audiodatei.";
|
|
console.error(error);
|
|
});
|
|
});
|