Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files- index.html +28 -3
index.html
CHANGED
|
@@ -138,8 +138,6 @@
|
|
| 138 |
top: 20px;
|
| 139 |
left: 50%;
|
| 140 |
transform: translateX(-50%);
|
| 141 |
-
background-color: #f44336;
|
| 142 |
-
color: white;
|
| 143 |
padding: 16px 24px;
|
| 144 |
border-radius: 4px;
|
| 145 |
font-size: 14px;
|
|
@@ -147,6 +145,16 @@
|
|
| 147 |
display: none;
|
| 148 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
| 149 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
</style>
|
| 151 |
</head>
|
| 152 |
|
|
@@ -236,9 +244,20 @@
|
|
| 236 |
async function setupWebRTC() {
|
| 237 |
isConnecting = true;
|
| 238 |
const config = __RTC_CONFIGURATION__;
|
| 239 |
-
|
| 240 |
peerConnection = new RTCPeerConnection(config);
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
try {
|
| 243 |
const stream = await navigator.mediaDevices.getUserMedia({
|
| 244 |
audio: true
|
|
@@ -284,6 +303,11 @@
|
|
| 284 |
|
| 285 |
peerConnection.addEventListener('connectionstatechange', () => {
|
| 286 |
console.log('connectionstatechange', peerConnection.connectionState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
updateButtonState();
|
| 288 |
});
|
| 289 |
|
|
@@ -318,6 +342,7 @@
|
|
| 318 |
|
| 319 |
});
|
| 320 |
} catch (err) {
|
|
|
|
| 321 |
console.error('Error setting up WebRTC:', err);
|
| 322 |
showError('Failed to establish connection. Please try again.');
|
| 323 |
stop();
|
|
|
|
| 138 |
top: 20px;
|
| 139 |
left: 50%;
|
| 140 |
transform: translateX(-50%);
|
|
|
|
|
|
|
| 141 |
padding: 16px 24px;
|
| 142 |
border-radius: 4px;
|
| 143 |
font-size: 14px;
|
|
|
|
| 145 |
display: none;
|
| 146 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
| 147 |
}
|
| 148 |
+
|
| 149 |
+
.toast.error {
|
| 150 |
+
background-color: #f44336;
|
| 151 |
+
color: white;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.toast.warning {
|
| 155 |
+
background-color: #ffd700;
|
| 156 |
+
color: black;
|
| 157 |
+
}
|
| 158 |
</style>
|
| 159 |
</head>
|
| 160 |
|
|
|
|
| 244 |
async function setupWebRTC() {
|
| 245 |
isConnecting = true;
|
| 246 |
const config = __RTC_CONFIGURATION__;
|
|
|
|
| 247 |
peerConnection = new RTCPeerConnection(config);
|
| 248 |
|
| 249 |
+
const timeoutId = setTimeout(() => {
|
| 250 |
+
const toast = document.getElementById('error-toast');
|
| 251 |
+
toast.textContent = "Connection is taking longer than usual. Are you on a VPN?";
|
| 252 |
+
toast.className = 'toast warning';
|
| 253 |
+
toast.style.display = 'block';
|
| 254 |
+
|
| 255 |
+
// Hide warning after 5 seconds
|
| 256 |
+
setTimeout(() => {
|
| 257 |
+
toast.style.display = 'none';
|
| 258 |
+
}, 5000);
|
| 259 |
+
}, 5000);
|
| 260 |
+
|
| 261 |
try {
|
| 262 |
const stream = await navigator.mediaDevices.getUserMedia({
|
| 263 |
audio: true
|
|
|
|
| 303 |
|
| 304 |
peerConnection.addEventListener('connectionstatechange', () => {
|
| 305 |
console.log('connectionstatechange', peerConnection.connectionState);
|
| 306 |
+
if (peerConnection.connectionState === 'connected') {
|
| 307 |
+
clearTimeout(timeoutId);
|
| 308 |
+
const toast = document.getElementById('error-toast');
|
| 309 |
+
toast.style.display = 'none';
|
| 310 |
+
}
|
| 311 |
updateButtonState();
|
| 312 |
});
|
| 313 |
|
|
|
|
| 342 |
|
| 343 |
});
|
| 344 |
} catch (err) {
|
| 345 |
+
clearTimeout(timeoutId);
|
| 346 |
console.error('Error setting up WebRTC:', err);
|
| 347 |
showError('Failed to establish connection. Please try again.');
|
| 348 |
stop();
|