Spaces:
Sleeping
Sleeping
Delete static/client.html
Browse files- static/client.html +0 -87
static/client.html
DELETED
|
@@ -1,87 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<title>Sign-to-Text API Smoke Test</title>
|
| 6 |
-
<style>
|
| 7 |
-
body { font-family: monospace; background: #111; color: #eee; padding: 20px; }
|
| 8 |
-
video { width: 480px; border: 1px solid #444; }
|
| 9 |
-
#log { margin-top: 20px; white-space: pre-wrap; background: #000; padding: 10px; height: 300px; overflow-y: auto; border: 1px solid #333; }
|
| 10 |
-
#status { margin-bottom: 10px; }
|
| 11 |
-
</style>
|
| 12 |
-
</head>
|
| 13 |
-
<body>
|
| 14 |
-
|
| 15 |
-
<h2>Sign-to-Text API -- Smoke Test (not the production frontend)</h2>
|
| 16 |
-
<div id="status">Status: not connected</div>
|
| 17 |
-
<video id="webcam" autoplay playsinline muted></video>
|
| 18 |
-
<div id="log"></div>
|
| 19 |
-
|
| 20 |
-
<script>
|
| 21 |
-
const TARGET_FPS = 15;
|
| 22 |
-
const statusEl = document.getElementById("status");
|
| 23 |
-
const logEl = document.getElementById("log");
|
| 24 |
-
const videoEl = document.getElementById("webcam");
|
| 25 |
-
|
| 26 |
-
function appendLog(message) {
|
| 27 |
-
const timestamp = new Date().toLocaleTimeString();
|
| 28 |
-
logEl.textContent += `[${timestamp}] ${message}\n`;
|
| 29 |
-
logEl.scrollTop = logEl.scrollHeight;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
async function main() {
|
| 33 |
-
const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 640, height: 480 }, audio: false });
|
| 34 |
-
videoEl.srcObject = stream;
|
| 35 |
-
await videoEl.play();
|
| 36 |
-
|
| 37 |
-
const canvas = document.createElement("canvas");
|
| 38 |
-
canvas.width = 640;
|
| 39 |
-
canvas.height = 480;
|
| 40 |
-
const ctx = canvas.getContext("2d");
|
| 41 |
-
|
| 42 |
-
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
| 43 |
-
const socket = new WebSocket(`${protocol}//${window.location.host}/ws`);
|
| 44 |
-
socket.binaryType = "arraybuffer";
|
| 45 |
-
|
| 46 |
-
socket.onopen = () => {
|
| 47 |
-
statusEl.textContent = "Status: connected, streaming frames";
|
| 48 |
-
appendLog("WebSocket connected.");
|
| 49 |
-
|
| 50 |
-
setInterval(() => {
|
| 51 |
-
if (socket.readyState !== WebSocket.OPEN) return;
|
| 52 |
-
ctx.drawImage(videoEl, 0, 0, canvas.width, canvas.height);
|
| 53 |
-
canvas.toBlob((blob) => {
|
| 54 |
-
if (blob) {
|
| 55 |
-
blob.arrayBuffer().then((buffer) => socket.send(buffer));
|
| 56 |
-
}
|
| 57 |
-
}, "image/jpeg", 0.8);
|
| 58 |
-
}, 1000 / TARGET_FPS);
|
| 59 |
-
};
|
| 60 |
-
|
| 61 |
-
socket.onmessage = (event) => {
|
| 62 |
-
const data = JSON.parse(event.data);
|
| 63 |
-
if (data.type === "segment") {
|
| 64 |
-
appendLog(`SEGMENT [${data.start_seconds.toFixed(1)}s - ${data.end_seconds.toFixed(1)}s]: "${data.text}" (dino=${data.dino_batch_ms.toFixed(0)}ms, translate=${data.translation_ms.toFixed(0)}ms)`);
|
| 65 |
-
} else if (data.type === "error") {
|
| 66 |
-
appendLog(`ERROR: ${data.message}`);
|
| 67 |
-
}
|
| 68 |
-
};
|
| 69 |
-
|
| 70 |
-
socket.onclose = () => {
|
| 71 |
-
statusEl.textContent = "Status: disconnected";
|
| 72 |
-
appendLog("WebSocket closed.");
|
| 73 |
-
};
|
| 74 |
-
|
| 75 |
-
socket.onerror = (err) => {
|
| 76 |
-
appendLog(`WebSocket error: ${err}`);
|
| 77 |
-
};
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
main().catch((err) => {
|
| 81 |
-
appendLog(`Failed to start: ${err}`);
|
| 82 |
-
statusEl.textContent = "Status: error -- check camera permissions";
|
| 83 |
-
});
|
| 84 |
-
</script>
|
| 85 |
-
|
| 86 |
-
</body>
|
| 87 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|