Spaces:
Running
Running
Update index.html
Browse files- index.html +36 -13
index.html
CHANGED
|
@@ -55,9 +55,9 @@
|
|
| 55 |
<div id="container">
|
| 56 |
<h1>Whisper WAV Transcription</h1>
|
| 57 |
|
| 58 |
-
<
|
| 59 |
-
<
|
| 60 |
-
|
| 61 |
<label for="audioFile">Select WAV File:</label>
|
| 62 |
<input type="file" id="audioFile" accept=".wav">
|
| 63 |
|
|
@@ -65,17 +65,41 @@
|
|
| 65 |
|
| 66 |
<div id="transcription"></div>
|
| 67 |
<button id="copyButton" onclick="copyToClipboard()" style="display: none;">Copy to Clipboard</button>
|
| 68 |
-
|
| 69 |
</div>
|
| 70 |
|
| 71 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
async function transcribeAudio() {
|
| 73 |
-
const apiKey = document.getElementById('apiKey').
|
| 74 |
-
const apiBaseUrl = document.getElementById('apiBaseUrl').
|
| 75 |
-
|
| 76 |
const audioFile = document.getElementById('audioFile').files[0];
|
| 77 |
const transcriptionDiv = document.getElementById('transcription');
|
| 78 |
-
|
| 79 |
if (!apiKey || !audioFile) {
|
| 80 |
console.log(apiKey);
|
| 81 |
alert('Please provide both API key and a WAV file.');
|
|
@@ -115,7 +139,7 @@
|
|
| 115 |
}
|
| 116 |
|
| 117 |
transcriptionDiv.innerHTML = fullTranscription;
|
| 118 |
-
|
| 119 |
|
| 120 |
} catch (error) {
|
| 121 |
console.error('Error during transcription:', error);
|
|
@@ -216,9 +240,8 @@
|
|
| 216 |
view.setUint8(offset + i, string.charCodeAt(i));
|
| 217 |
}
|
| 218 |
}
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
function copyToClipboard() {
|
| 222 |
const transcriptionText = document.getElementById('transcription').innerText;
|
| 223 |
navigator.clipboard.writeText(transcriptionText)
|
| 224 |
.then(() => {
|
|
@@ -230,4 +253,4 @@
|
|
| 230 |
}
|
| 231 |
</script>
|
| 232 |
</body>
|
| 233 |
-
</html>
|
|
|
|
| 55 |
<div id="container">
|
| 56 |
<h1>Whisper WAV Transcription</h1>
|
| 57 |
|
| 58 |
+
<input type="hidden" id="apiKey"> <!-- Hidden input for API key -->
|
| 59 |
+
<input type="hidden" id="apiBaseUrl"> <!-- Hidden input for API base URL -->
|
| 60 |
+
|
| 61 |
<label for="audioFile">Select WAV File:</label>
|
| 62 |
<input type="file" id="audioFile" accept=".wav">
|
| 63 |
|
|
|
|
| 65 |
|
| 66 |
<div id="transcription"></div>
|
| 67 |
<button id="copyButton" onclick="copyToClipboard()" style="display: none;">Copy to Clipboard</button>
|
|
|
|
| 68 |
</div>
|
| 69 |
|
| 70 |
<script>
|
| 71 |
+
// Function to extract parameters from URL hash
|
| 72 |
+
function getHashParams() {
|
| 73 |
+
const hash = window.location.hash.substring(1);
|
| 74 |
+
const params = {};
|
| 75 |
+
|
| 76 |
+
hash.split('&').forEach(part => {
|
| 77 |
+
const [key, value] = part.split('=');
|
| 78 |
+
if (key && value) {
|
| 79 |
+
params[key] = decodeURIComponent(value);
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
return params;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
// Set apiKey and apiBaseUrl from URL hash
|
| 87 |
+
window.onload = () => {
|
| 88 |
+
const params = getHashParams();
|
| 89 |
+
document.getElementById('apiKey').value = params.apiKey || '';
|
| 90 |
+
document.getElementById('apiBaseUrl').value = params.apiBaseUrl || '';
|
| 91 |
+
|
| 92 |
+
if (!params.apiKey || !params.apiBaseUrl) {
|
| 93 |
+
alert('Please provide both apiKey and apiBaseUrl in the URL hash.');
|
| 94 |
+
}
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
async function transcribeAudio() {
|
| 98 |
+
const apiKey = document.getElementById('apiKey').value;
|
| 99 |
+
const apiBaseUrl = document.getElementById('apiBaseUrl').value;
|
|
|
|
| 100 |
const audioFile = document.getElementById('audioFile').files[0];
|
| 101 |
const transcriptionDiv = document.getElementById('transcription');
|
| 102 |
+
|
| 103 |
if (!apiKey || !audioFile) {
|
| 104 |
console.log(apiKey);
|
| 105 |
alert('Please provide both API key and a WAV file.');
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
transcriptionDiv.innerHTML = fullTranscription;
|
| 142 |
+
document.getElementById('copyButton').style.display = 'block'; // Show copy button
|
| 143 |
|
| 144 |
} catch (error) {
|
| 145 |
console.error('Error during transcription:', error);
|
|
|
|
| 240 |
view.setUint8(offset + i, string.charCodeAt(i));
|
| 241 |
}
|
| 242 |
}
|
| 243 |
+
|
| 244 |
+
function copyToClipboard() {
|
|
|
|
| 245 |
const transcriptionText = document.getElementById('transcription').innerText;
|
| 246 |
navigator.clipboard.writeText(transcriptionText)
|
| 247 |
.then(() => {
|
|
|
|
| 253 |
}
|
| 254 |
</script>
|
| 255 |
</body>
|
| 256 |
+
</html>
|