Spaces:
No application file
No application file
Create templets/index.html
Browse files- templets/index.html +68 -0
templets/index.html
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<title>Upload audio files — merged DOCX</title>
|
| 6 |
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: Arial, sans-serif; max-width: 880px; margin: 2rem auto; color: #222; }
|
| 9 |
+
h1 { font-size: 1.5rem; }
|
| 10 |
+
.dropzone { border: 2px dashed #888; padding: 1.5rem; text-align: center; margin-bottom: 1rem; }
|
| 11 |
+
input[type=file] { display: block; margin: 0.5rem auto; }
|
| 12 |
+
button { padding: 0.6rem 1rem; font-size: 1rem; }
|
| 13 |
+
.note { color: #555; font-size: .9rem; margin-top: .5rem; }
|
| 14 |
+
</style>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<h1>Upload audio files (multiple) — get a single merged Word document</h1>
|
| 18 |
+
<div class="dropzone">
|
| 19 |
+
<form id="upload-form" method="post" enctype="multipart/form-data" action="/transcribe">
|
| 20 |
+
<input id="files" name="files" type="file" accept=".wav,.mp3,.m4a,.flac,.aac,.ogg" multiple required>
|
| 21 |
+
<div class="note">Allowed: wav, mp3, m4a, flac, aac, ogg. Max files: {{ max_files }}.</div>
|
| 22 |
+
<div style="margin-top:1rem;"><button type="button" id="submit">Upload and Merge</button></div>
|
| 23 |
+
</form>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div id="status"></div>
|
| 27 |
+
|
| 28 |
+
<script>
|
| 29 |
+
const submitBtn = document.getElementById('submit');
|
| 30 |
+
const form = document.getElementById('upload-form');
|
| 31 |
+
const status = document.getElementById('status');
|
| 32 |
+
submitBtn.addEventListener('click', async () => {
|
| 33 |
+
const input = document.getElementById('files');
|
| 34 |
+
if (!input.files.length) {
|
| 35 |
+
alert('Please select one or more audio files.');
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
if (input.files.length > {{ max_files }}) {
|
| 39 |
+
alert('Too many files selected (max {{ max_files }}).');
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
const fd = new FormData();
|
| 43 |
+
for (const f of input.files) {
|
| 44 |
+
fd.append('files', f, f.name);
|
| 45 |
+
}
|
| 46 |
+
status.textContent = 'Uploading and transcribing... (this may take some time)';
|
| 47 |
+
try {
|
| 48 |
+
const resp = await fetch('/transcribe', { method: 'POST', body: fd });
|
| 49 |
+
if (!resp.ok) {
|
| 50 |
+
const body = await resp.json().catch(()=>({}));
|
| 51 |
+
status.textContent = 'Error: ' + (body.error || resp.statusText);
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
const blob = await resp.blob();
|
| 55 |
+
const url = URL.createObjectURL(blob);
|
| 56 |
+
const a = document.createElement('a');
|
| 57 |
+
a.href = url;
|
| 58 |
+
a.download = 'merged_transcripts.docx';
|
| 59 |
+
a.textContent = 'Download merged_transcripts.docx';
|
| 60 |
+
status.innerHTML = '';
|
| 61 |
+
status.appendChild(a);
|
| 62 |
+
} catch (e) {
|
| 63 |
+
status.textContent = 'Upload failed: ' + e.toString();
|
| 64 |
+
}
|
| 65 |
+
});
|
| 66 |
+
</script>
|
| 67 |
+
</body>
|
| 68 |
+
</html>
|