format html and change mapping id <-> speakers
Browse files- src/web/live_transcription.html +340 -318
src/web/live_transcription.html
CHANGED
@@ -1,339 +1,361 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
|
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
@keyframes spin {
|
116 |
-
|
117 |
-
|
|
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
-
|
121 |
-
color: #666;
|
122 |
-
background-color: #f3f3f3;
|
123 |
-
font-size: 13px;
|
124 |
-
border-radius: 30px;
|
125 |
-
padding: 2px 10px;
|
126 |
-
}
|
127 |
-
.loading {
|
128 |
-
color: #666;
|
129 |
-
background-color: #eff9ff;
|
130 |
-
font-size: 14px;
|
131 |
-
border-radius: 30px;
|
132 |
-
padding: 2px 10px;
|
133 |
-
}
|
134 |
-
</style>
|
135 |
</head>
|
|
|
136 |
<body>
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
156 |
</div>
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
} else {
|
211 |
-
statusText.textContent =
|
212 |
-
"Disconnected from the WebSocket server. (Check logs if model is loading.)";
|
213 |
-
}
|
214 |
-
userClosing = false;
|
215 |
-
};
|
216 |
-
|
217 |
-
websocket.onerror = () => {
|
218 |
-
statusText.textContent = "Error connecting to WebSocket.";
|
219 |
-
reject(new Error("Error connecting to WebSocket"));
|
220 |
-
};
|
221 |
-
|
222 |
-
// Handle messages from server
|
223 |
-
websocket.onmessage = (event) => {
|
224 |
-
const data = JSON.parse(event.data);
|
225 |
-
/*
|
226 |
-
The server might send:
|
227 |
-
{
|
228 |
-
"lines": [
|
229 |
-
{"speaker": 0, "text": "Hello.", "beg": "00:00", "end": "00:01"},
|
230 |
-
{"speaker": -2, "text": "Hi, no speaker here.", "beg": "00:01", "end": "00:02"},
|
231 |
-
{"speaker": -1, "text": "...", "beg": "00:02", "end": "00:03" },
|
232 |
-
...
|
233 |
-
],
|
234 |
-
"buffer": "..."
|
235 |
}
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
}
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
let textContent = item.text;
|
272 |
-
if (idx === lines.length - 1 && buffer) {
|
273 |
-
textContent += `<span class="buffer">${buffer}</span>`;
|
274 |
}
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
}).join("");
|
280 |
-
|
281 |
-
linesTranscriptDiv.innerHTML = linesHtml;
|
282 |
-
}
|
283 |
-
|
284 |
-
async function startRecording() {
|
285 |
-
try {
|
286 |
-
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
287 |
-
recorder = new MediaRecorder(stream, { mimeType: "audio/webm" });
|
288 |
-
recorder.ondataavailable = (e) => {
|
289 |
-
if (websocket && websocket.readyState === WebSocket.OPEN) {
|
290 |
-
websocket.send(e.data);
|
291 |
-
}
|
292 |
-
};
|
293 |
-
recorder.start(chunkDuration);
|
294 |
-
isRecording = true;
|
295 |
-
updateUI();
|
296 |
-
} catch (err) {
|
297 |
-
statusText.textContent = "Error accessing microphone. Please allow microphone access.";
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
function stopRecording() {
|
302 |
-
userClosing = true;
|
303 |
-
if (recorder) {
|
304 |
-
recorder.stop();
|
305 |
-
recorder = null;
|
306 |
-
}
|
307 |
-
isRecording = false;
|
308 |
-
|
309 |
-
if (websocket) {
|
310 |
-
websocket.close();
|
311 |
-
websocket = null;
|
312 |
-
}
|
313 |
-
|
314 |
-
updateUI();
|
315 |
-
}
|
316 |
-
|
317 |
-
async function toggleRecording() {
|
318 |
-
if (!isRecording) {
|
319 |
-
linesTranscriptDiv.innerHTML = "";
|
320 |
-
try {
|
321 |
-
await setupWebSocket();
|
322 |
-
await startRecording();
|
323 |
-
} catch (err) {
|
324 |
-
statusText.textContent = "Could not connect to WebSocket or access mic. Aborted.";
|
325 |
}
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
function updateUI() {
|
332 |
-
recordButton.classList.toggle("recording", isRecording);
|
333 |
-
statusText.textContent = isRecording ? "Recording..." : "Click to start transcription";
|
334 |
-
}
|
335 |
-
|
336 |
-
recordButton.addEventListener("click", toggleRecording);
|
337 |
-
</script>
|
338 |
</body>
|
|
|
339 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
+
|
4 |
<head>
|
5 |
+
<meta charset="UTF-8" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
+
<title>Audio Transcription</title>
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: 'Inter', sans-serif;
|
11 |
+
margin: 20px;
|
12 |
+
text-align: center;
|
13 |
+
}
|
14 |
+
|
15 |
+
#recordButton {
|
16 |
+
width: 80px;
|
17 |
+
height: 80px;
|
18 |
+
font-size: 36px;
|
19 |
+
border: none;
|
20 |
+
border-radius: 50%;
|
21 |
+
background-color: white;
|
22 |
+
cursor: pointer;
|
23 |
+
box-shadow: 0 0px 10px rgba(0, 0, 0, 0.2);
|
24 |
+
transition: background-color 0.3s ease, transform 0.2s ease;
|
25 |
+
}
|
26 |
+
|
27 |
+
#recordButton.recording {
|
28 |
+
background-color: #ff4d4d;
|
29 |
+
color: white;
|
30 |
+
}
|
31 |
+
|
32 |
+
#recordButton:active {
|
33 |
+
transform: scale(0.95);
|
34 |
+
}
|
35 |
+
|
36 |
+
#status {
|
37 |
+
margin-top: 20px;
|
38 |
+
font-size: 16px;
|
39 |
+
color: #333;
|
40 |
+
}
|
41 |
+
|
42 |
+
.settings-container {
|
43 |
+
display: flex;
|
44 |
+
justify-content: center;
|
45 |
+
align-items: center;
|
46 |
+
gap: 15px;
|
47 |
+
margin-top: 20px;
|
48 |
+
}
|
49 |
+
|
50 |
+
.settings {
|
51 |
+
display: flex;
|
52 |
+
flex-direction: column;
|
53 |
+
align-items: flex-start;
|
54 |
+
gap: 5px;
|
55 |
+
}
|
56 |
+
|
57 |
+
#chunkSelector,
|
58 |
+
#websocketInput {
|
59 |
+
font-size: 16px;
|
60 |
+
padding: 5px;
|
61 |
+
border-radius: 5px;
|
62 |
+
border: 1px solid #ddd;
|
63 |
+
background-color: #f9f9f9;
|
64 |
+
}
|
65 |
+
|
66 |
+
#websocketInput {
|
67 |
+
width: 200px;
|
68 |
+
}
|
69 |
+
|
70 |
+
#chunkSelector:focus,
|
71 |
+
#websocketInput:focus {
|
72 |
+
outline: none;
|
73 |
+
border-color: #007bff;
|
74 |
+
}
|
75 |
+
|
76 |
+
label {
|
77 |
+
font-size: 14px;
|
78 |
+
}
|
79 |
+
|
80 |
+
/* Speaker-labeled transcript area */
|
81 |
+
#linesTranscript {
|
82 |
+
margin: 20px auto;
|
83 |
+
max-width: 600px;
|
84 |
+
text-align: left;
|
85 |
+
font-size: 16px;
|
86 |
+
}
|
87 |
+
|
88 |
+
#linesTranscript p {
|
89 |
+
margin: 5px 0;
|
90 |
+
}
|
91 |
+
|
92 |
+
#linesTranscript strong {
|
93 |
+
color: #333;
|
94 |
+
}
|
95 |
+
|
96 |
+
#speaker {
|
97 |
+
background-color: #dcefff;
|
98 |
+
border-radius: 30px;
|
99 |
+
padding: 2px 10px;
|
100 |
+
font-size: 14px;
|
101 |
+
}
|
102 |
+
|
103 |
+
#timeInfo {
|
104 |
+
color: #666;
|
105 |
+
margin-left: 10px;
|
106 |
+
}
|
107 |
+
|
108 |
+
.textcontent {
|
109 |
+
font-size: 16px;
|
110 |
+
margin-left: 10px;
|
111 |
+
padding-left: 10px;
|
112 |
+
border-left: 2px solid #dcefff;
|
113 |
+
margin-bottom: 10px;
|
114 |
+
}
|
115 |
+
|
116 |
+
.buffer {
|
117 |
+
color: rgb(180, 180, 180);
|
118 |
+
font-style: italic;
|
119 |
+
margin-left: 4px;
|
120 |
+
}
|
121 |
+
|
122 |
+
.spinner {
|
123 |
+
display: inline-block;
|
124 |
+
width: 8px;
|
125 |
+
height: 8px;
|
126 |
+
border: 2px solid rgba(0, 0, 0, 0.2);
|
127 |
+
border-top: 2px solid #333;
|
128 |
+
border-radius: 50%;
|
129 |
+
animation: spin 0.6s linear infinite;
|
130 |
+
vertical-align: middle;
|
131 |
+
margin-bottom: 2px;
|
132 |
}
|
133 |
|
134 |
@keyframes spin {
|
135 |
+
to {
|
136 |
+
transform: rotate(360deg);
|
137 |
+
}
|
138 |
}
|
139 |
+
|
140 |
+
.silence {
|
141 |
+
color: #666;
|
142 |
+
background-color: #f3f3f3;
|
143 |
+
font-size: 13px;
|
144 |
+
border-radius: 30px;
|
145 |
+
padding: 2px 10px;
|
146 |
+
}
|
147 |
+
|
148 |
+
.loading {
|
149 |
+
color: #666;
|
150 |
+
background-color: #eff9ff;
|
151 |
+
font-size: 14px;
|
152 |
+
border-radius: 30px;
|
153 |
+
padding: 2px 10px;
|
154 |
}
|
155 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
</head>
|
157 |
+
|
158 |
<body>
|
159 |
|
160 |
+
<div class="settings-container">
|
161 |
+
<button id="recordButton">🎙️</button>
|
162 |
+
<div class="settings">
|
163 |
+
<div>
|
164 |
+
<label for="chunkSelector">Chunk size (ms):</label>
|
165 |
+
<select id="chunkSelector">
|
166 |
+
<option value="500">500 ms</option>
|
167 |
+
<option value="1000" selected>1000 ms</option>
|
168 |
+
<option value="2000">2000 ms</option>
|
169 |
+
<option value="3000">3000 ms</option>
|
170 |
+
<option value="4000">4000 ms</option>
|
171 |
+
<option value="5000">5000 ms</option>
|
172 |
+
</select>
|
173 |
+
</div>
|
174 |
+
<div>
|
175 |
+
<label for="websocketInput">WebSocket URL:</label>
|
176 |
+
<input id="websocketInput" type="text" value="ws://localhost:8000/asr" />
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
</div>
|
180 |
+
|
181 |
+
<p id="status"></p>
|
182 |
+
|
183 |
+
<!-- Speaker-labeled transcript -->
|
184 |
+
<div id="linesTranscript"></div>
|
185 |
+
|
186 |
+
<script>
|
187 |
+
let isRecording = false;
|
188 |
+
let websocket = null;
|
189 |
+
let recorder = null;
|
190 |
+
let chunkDuration = 1000;
|
191 |
+
let websocketUrl = "ws://localhost:8000/asr";
|
192 |
+
let userClosing = false;
|
193 |
+
|
194 |
+
const statusText = document.getElementById("status");
|
195 |
+
const recordButton = document.getElementById("recordButton");
|
196 |
+
const chunkSelector = document.getElementById("chunkSelector");
|
197 |
+
const websocketInput = document.getElementById("websocketInput");
|
198 |
+
const linesTranscriptDiv = document.getElementById("linesTranscript");
|
199 |
+
|
200 |
+
chunkSelector.addEventListener("change", () => {
|
201 |
+
chunkDuration = parseInt(chunkSelector.value);
|
202 |
+
});
|
203 |
+
|
204 |
+
websocketInput.addEventListener("change", () => {
|
205 |
+
const urlValue = websocketInput.value.trim();
|
206 |
+
if (!urlValue.startsWith("ws://") && !urlValue.startsWith("wss://")) {
|
207 |
+
statusText.textContent = "Invalid WebSocket URL (must start with ws:// or wss://)";
|
208 |
+
return;
|
209 |
+
}
|
210 |
+
websocketUrl = urlValue;
|
211 |
+
statusText.textContent = "WebSocket URL updated. Ready to connect.";
|
212 |
+
});
|
213 |
+
|
214 |
+
function setupWebSocket() {
|
215 |
+
return new Promise((resolve, reject) => {
|
216 |
+
try {
|
217 |
+
websocket = new WebSocket(websocketUrl);
|
218 |
+
} catch (error) {
|
219 |
+
statusText.textContent = "Invalid WebSocket URL. Please check and try again.";
|
220 |
+
reject(error);
|
221 |
+
return;
|
222 |
+
}
|
223 |
+
|
224 |
+
websocket.onopen = () => {
|
225 |
+
statusText.textContent = "Connected to server.";
|
226 |
+
resolve();
|
227 |
+
};
|
228 |
+
|
229 |
+
websocket.onclose = () => {
|
230 |
+
if (userClosing) {
|
231 |
+
statusText.textContent = "WebSocket closed by user.";
|
232 |
+
} else {
|
233 |
+
statusText.textContent =
|
234 |
+
"Disconnected from the WebSocket server. (Check logs if model is loading.)";
|
235 |
+
}
|
236 |
+
userClosing = false;
|
237 |
+
};
|
238 |
+
|
239 |
+
websocket.onerror = () => {
|
240 |
+
statusText.textContent = "Error connecting to WebSocket.";
|
241 |
+
reject(new Error("Error connecting to WebSocket"));
|
242 |
+
};
|
243 |
+
|
244 |
+
// Handle messages from server
|
245 |
+
websocket.onmessage = (event) => {
|
246 |
+
const data = JSON.parse(event.data);
|
247 |
+
/*
|
248 |
+
The server might send:
|
249 |
+
{
|
250 |
+
"lines": [
|
251 |
+
{"speaker": 0, "text": "Hello.", "beg": "00:00", "end": "00:01"},
|
252 |
+
{"speaker": -2, "text": "Hi, no speaker here.", "beg": "00:01", "end": "00:02"},
|
253 |
+
{"speaker": -1, "text": "...", "beg": "00:02", "end": "00:03" },
|
254 |
+
...
|
255 |
+
],
|
256 |
+
"buffer": "..."
|
257 |
+
}
|
258 |
+
*/
|
259 |
+
const { lines = [], buffer = "" } = data;
|
260 |
+
renderLinesWithBuffer(lines, buffer);
|
261 |
+
};
|
262 |
+
});
|
263 |
}
|
264 |
|
265 |
+
function renderLinesWithBuffer(lines, buffer) {
|
266 |
+
if (!Array.isArray(lines) || lines.length === 0) {
|
267 |
+
if (buffer) {
|
268 |
+
linesTranscriptDiv.innerHTML = `<span class="buffer">${buffer}</span>`;
|
269 |
+
} else {
|
270 |
+
linesTranscriptDiv.innerHTML = "";
|
271 |
+
}
|
272 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
}
|
274 |
+
|
275 |
+
const linesHtml = lines.map((item, idx) => {
|
276 |
+
let timeInfo = "";
|
277 |
+
if (item.beg !== undefined && item.end !== undefined) {
|
278 |
+
timeInfo = ` ${item.beg} - ${item.end}`;
|
279 |
+
}
|
280 |
+
|
281 |
+
let speakerLabel = "";
|
282 |
+
if (item.speaker === -2) {
|
283 |
+
speakerLabel = `<span class="silence">Silence<span id='timeInfo'>${timeInfo}</span></span>`;
|
284 |
+
} else if (item.speaker == 0) {
|
285 |
+
speakerLabel = `<span class='loading'><span class="spinner"></span><span id='timeInfo'>${item.diff} second(s) of audio are undergoing diarization</span></span>`;
|
286 |
+
} else if (item.speaker == -1) {
|
287 |
+
speakerLabel = `<span id="speaker"><span id='timeInfo'>${timeInfo}</span>`;
|
288 |
+
} else if (item.speaker !== -1) {
|
289 |
+
speakerLabel = `<span id="speaker">Speaker ${item.speaker}<span id='timeInfo'>${timeInfo}</span></span>`;
|
290 |
+
}
|
291 |
+
|
292 |
+
let textContent = item.text;
|
293 |
+
if (idx === lines.length - 1 && buffer) {
|
294 |
+
textContent += `<span class="buffer">${buffer}</span>`;
|
295 |
+
}
|
296 |
+
|
297 |
+
return textContent
|
298 |
+
? `<p>${speakerLabel}<br/><div class='textcontent'>${textContent}</div></p>`
|
299 |
+
: `<p>${speakerLabel}<br/></p>`;
|
300 |
+
}).join("");
|
301 |
+
|
302 |
+
linesTranscriptDiv.innerHTML = linesHtml;
|
303 |
+
}
|
304 |
+
|
305 |
+
async function startRecording() {
|
306 |
+
try {
|
307 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
308 |
+
recorder = new MediaRecorder(stream, { mimeType: "audio/webm" });
|
309 |
+
recorder.ondataavailable = (e) => {
|
310 |
+
if (websocket && websocket.readyState === WebSocket.OPEN) {
|
311 |
+
websocket.send(e.data);
|
312 |
+
}
|
313 |
+
};
|
314 |
+
recorder.start(chunkDuration);
|
315 |
+
isRecording = true;
|
316 |
+
updateUI();
|
317 |
+
} catch (err) {
|
318 |
+
statusText.textContent = "Error accessing microphone. Please allow microphone access.";
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
function stopRecording() {
|
323 |
+
userClosing = true;
|
324 |
+
if (recorder) {
|
325 |
+
recorder.stop();
|
326 |
+
recorder = null;
|
327 |
+
}
|
328 |
+
isRecording = false;
|
329 |
+
|
330 |
+
if (websocket) {
|
331 |
+
websocket.close();
|
332 |
+
websocket = null;
|
333 |
+
}
|
334 |
+
|
335 |
+
updateUI();
|
336 |
}
|
337 |
|
338 |
+
async function toggleRecording() {
|
339 |
+
if (!isRecording) {
|
340 |
+
linesTranscriptDiv.innerHTML = "";
|
341 |
+
try {
|
342 |
+
await setupWebSocket();
|
343 |
+
await startRecording();
|
344 |
+
} catch (err) {
|
345 |
+
statusText.textContent = "Could not connect to WebSocket or access mic. Aborted.";
|
346 |
+
}
|
347 |
+
} else {
|
348 |
+
stopRecording();
|
349 |
+
}
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
+
|
352 |
+
function updateUI() {
|
353 |
+
recordButton.classList.toggle("recording", isRecording);
|
354 |
+
statusText.textContent = isRecording ? "Recording..." : "Click to start transcription";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
+
|
357 |
+
recordButton.addEventListener("click", toggleRecording);
|
358 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
</body>
|
360 |
+
|
361 |
</html>
|