Spaces:
Running
Running
show mic status (2)
Browse files- app/static/index.html +13 -4
app/static/index.html
CHANGED
@@ -201,6 +201,8 @@
|
|
201 |
model: modelSelect.value,
|
202 |
precision: precisionSelect.value
|
203 |
}));
|
|
|
|
|
204 |
}
|
205 |
}
|
206 |
|
@@ -215,21 +217,28 @@
|
|
215 |
|
216 |
updateModelInfo();
|
217 |
|
218 |
-
//
|
219 |
-
ws = new WebSocket(`
|
220 |
ws.onopen = () => sendConfig();
|
221 |
ws.onerror = err => console.error("WebSocket error:", err);
|
222 |
ws.onclose = () => console.log("WebSocket closed");
|
223 |
ws.onmessage = e => {
|
224 |
const msg = JSON.parse(e.data);
|
225 |
-
if (msg.volume !== undefined)
|
|
|
|
|
226 |
if (msg.partial) {
|
|
|
227 |
transcript.textContent = msg.partial;
|
|
|
228 |
transcript.scrollTop = transcript.scrollHeight;
|
229 |
}
|
230 |
};
|
231 |
|
232 |
-
modelSelect.addEventListener("change", () => {
|
|
|
|
|
|
|
233 |
precisionSelect.addEventListener("change", sendConfig);
|
234 |
|
235 |
const source = context.createMediaStreamSource(stream);
|
|
|
201 |
model: modelSelect.value,
|
202 |
precision: precisionSelect.value
|
203 |
}));
|
204 |
+
} else {
|
205 |
+
console.warn("WebSocket not open yet. Cannot send config.");
|
206 |
}
|
207 |
}
|
208 |
|
|
|
217 |
|
218 |
updateModelInfo();
|
219 |
|
220 |
+
// Now that we know the sample rate, open the WS
|
221 |
+
ws = new WebSocket(`wss://${location.host}/ws`);
|
222 |
ws.onopen = () => sendConfig();
|
223 |
ws.onerror = err => console.error("WebSocket error:", err);
|
224 |
ws.onclose = () => console.log("WebSocket closed");
|
225 |
ws.onmessage = e => {
|
226 |
const msg = JSON.parse(e.data);
|
227 |
+
if (msg.volume !== undefined) {
|
228 |
+
vol.value = Math.min(msg.volume * 20.0, 1.0);
|
229 |
+
}
|
230 |
if (msg.partial) {
|
231 |
+
// replace content…
|
232 |
transcript.textContent = msg.partial;
|
233 |
+
// …then scroll to bottom
|
234 |
transcript.scrollTop = transcript.scrollHeight;
|
235 |
}
|
236 |
};
|
237 |
|
238 |
+
modelSelect.addEventListener("change", () => {
|
239 |
+
updateModelInfo();
|
240 |
+
sendConfig();
|
241 |
+
});
|
242 |
precisionSelect.addEventListener("change", sendConfig);
|
243 |
|
244 |
const source = context.createMediaStreamSource(stream);
|