Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files- index.html +15 -14
index.html
CHANGED
@@ -394,6 +394,21 @@
|
|
394 |
updateButtonState();
|
395 |
});
|
396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
peerConnection.addEventListener('track', (evt) => {
|
398 |
if (evt.track.kind === 'audio' && audioOutput) {
|
399 |
if (audioOutput.srcObject !== evt.streams[0]) {
|
@@ -441,20 +456,6 @@
|
|
441 |
const offer = await peerConnection.createOffer();
|
442 |
await peerConnection.setLocalDescription(offer);
|
443 |
|
444 |
-
await new Promise((resolve) => {
|
445 |
-
if (peerConnection.iceGatheringState === "complete") {
|
446 |
-
resolve();
|
447 |
-
} else {
|
448 |
-
const checkState = () => {
|
449 |
-
if (peerConnection.iceGatheringState === "complete") {
|
450 |
-
peerConnection.removeEventListener("icegatheringstatechange", checkState);
|
451 |
-
resolve();
|
452 |
-
}
|
453 |
-
};
|
454 |
-
peerConnection.addEventListener("icegatheringstatechange", checkState);
|
455 |
-
}
|
456 |
-
});
|
457 |
-
|
458 |
const response = await fetch('/webrtc/offer', {
|
459 |
method: 'POST',
|
460 |
headers: { 'Content-Type': 'application/json' },
|
|
|
394 |
updateButtonState();
|
395 |
});
|
396 |
|
397 |
+
peerConnection.onicecandidate = ({ candidate }) => {
|
398 |
+
if (candidate) {
|
399 |
+
console.debug("Sending ICE candidate", candidate);
|
400 |
+
fetch('/webrtc/offer', {
|
401 |
+
method: 'POST',
|
402 |
+
headers: { 'Content-Type': 'application/json' },
|
403 |
+
body: JSON.stringify({
|
404 |
+
candidate: candidate.toJSON(),
|
405 |
+
webrtc_id: webrtc_id,
|
406 |
+
type: "ice-candidate",
|
407 |
+
})
|
408 |
+
})
|
409 |
+
}
|
410 |
+
};
|
411 |
+
|
412 |
peerConnection.addEventListener('track', (evt) => {
|
413 |
if (evt.track.kind === 'audio' && audioOutput) {
|
414 |
if (audioOutput.srcObject !== evt.streams[0]) {
|
|
|
456 |
const offer = await peerConnection.createOffer();
|
457 |
await peerConnection.setLocalDescription(offer);
|
458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
const response = await fetch('/webrtc/offer', {
|
460 |
method: 'POST',
|
461 |
headers: { 'Content-Type': 'application/json' },
|