Spaces:
Runtime error
Runtime error
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>LiveKit Object Detection</title> | |
<script src="https://cdn.livekit.io/livekit-client.min.js"></script> | |
<style> | |
body { | |
background: #191731; | |
color: white; | |
font-family: sans-serif; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
justify-content: center; | |
height: 100vh; | |
} | |
video { | |
width: 500px; | |
height: 500px; | |
background: #222; | |
} | |
.controls { | |
margin-top: 20px; | |
} | |
input[type="range"] { | |
width: 300px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Real-Time Detection with LiveKit</h1> | |
<video id="video-output" autoplay muted playsinline></video> | |
<div class="controls"> | |
<label>Confidence Threshold: <span id="conf-value">0.3</span></label><br /> | |
<input type="range" min="0" max="1" step="0.01" value="0.3" id="conf-threshold" /> | |
</div> | |
<script> | |
const token = "wss://myvoiceassistant-h4f2cbzj.livekit.cloud"; // Replace with server-side injection or hardcode for dev | |
const confSlider = document.getElementById("conf-threshold"); | |
const confValue = document.getElementById("conf-value"); | |
const videoOutput = document.getElementById("video-output"); | |
async function startLiveKit() { | |
const room = new Livekit.Room(); | |
await room.connect("wss://your-livekit-server-url", token); | |
const mediaStream = await navigator.mediaDevices.getUserMedia({ video: true }); | |
const track = await Livekit.createLocalVideoTrack({ deviceId: mediaStream.getVideoTracks()[0].getSettings().deviceId }); | |
await room.localParticipant.publishTrack(track); | |
videoOutput.srcObject = new MediaStream([track.mediaStreamTrack]); | |
confSlider.addEventListener("input", (e) => { | |
confValue.textContent = e.target.value; | |
fetch("/input_hook", { | |
method: "POST", | |
headers: { "Content-Type": "application/json" }, | |
body: JSON.stringify({ | |
webrtc_id: "livekit_user", // Static ID for now | |
conf_threshold: parseFloat(e.target.value), | |
}), | |
}); | |
}); | |
} | |
startLiveKit(); | |
</script> | |
</body> | |
</html> | |