Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- index.html +28 -2
index.html
CHANGED
|
@@ -120,8 +120,6 @@
|
|
| 120 |
top: 20px;
|
| 121 |
left: 50%;
|
| 122 |
transform: translateX(-50%);
|
| 123 |
-
background-color: #f44336;
|
| 124 |
-
color: white;
|
| 125 |
padding: 16px 24px;
|
| 126 |
border-radius: 4px;
|
| 127 |
font-size: 14px;
|
|
@@ -130,6 +128,16 @@
|
|
| 130 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
| 131 |
}
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
/* Add styles for audio visualization */
|
| 134 |
.icon-with-spinner {
|
| 135 |
display: flex;
|
|
@@ -268,6 +276,18 @@
|
|
| 268 |
const config = __RTC_CONFIGURATION__;
|
| 269 |
peerConnection = new RTCPeerConnection(config);
|
| 270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
try {
|
| 272 |
const stream = await navigator.mediaDevices.getUserMedia({
|
| 273 |
audio: true
|
|
@@ -282,6 +302,11 @@
|
|
| 282 |
// Add connection state change listener
|
| 283 |
peerConnection.addEventListener('connectionstatechange', () => {
|
| 284 |
console.log('connectionstatechange', peerConnection.connectionState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
updateButtonState();
|
| 286 |
});
|
| 287 |
|
|
@@ -338,6 +363,7 @@
|
|
| 338 |
appendTranscript(event.data);
|
| 339 |
});
|
| 340 |
} catch (err) {
|
|
|
|
| 341 |
console.error('Error setting up WebRTC:', err);
|
| 342 |
showError('Failed to establish connection. Please try again.');
|
| 343 |
stop();
|
|
|
|
| 120 |
top: 20px;
|
| 121 |
left: 50%;
|
| 122 |
transform: translateX(-50%);
|
|
|
|
|
|
|
| 123 |
padding: 16px 24px;
|
| 124 |
border-radius: 4px;
|
| 125 |
font-size: 14px;
|
|
|
|
| 128 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
| 129 |
}
|
| 130 |
|
| 131 |
+
.toast.error {
|
| 132 |
+
background-color: #f44336;
|
| 133 |
+
color: white;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.toast.warning {
|
| 137 |
+
background-color: #ffd700;
|
| 138 |
+
color: black;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
/* Add styles for audio visualization */
|
| 142 |
.icon-with-spinner {
|
| 143 |
display: flex;
|
|
|
|
| 276 |
const config = __RTC_CONFIGURATION__;
|
| 277 |
peerConnection = new RTCPeerConnection(config);
|
| 278 |
|
| 279 |
+
const timeoutId = setTimeout(() => {
|
| 280 |
+
const toast = document.getElementById('error-toast');
|
| 281 |
+
toast.textContent = "Connection is taking longer than usual. Are you on a VPN?";
|
| 282 |
+
toast.className = 'toast warning';
|
| 283 |
+
toast.style.display = 'block';
|
| 284 |
+
|
| 285 |
+
// Hide warning after 5 seconds
|
| 286 |
+
setTimeout(() => {
|
| 287 |
+
toast.style.display = 'none';
|
| 288 |
+
}, 5000);
|
| 289 |
+
}, 5000);
|
| 290 |
+
|
| 291 |
try {
|
| 292 |
const stream = await navigator.mediaDevices.getUserMedia({
|
| 293 |
audio: true
|
|
|
|
| 302 |
// Add connection state change listener
|
| 303 |
peerConnection.addEventListener('connectionstatechange', () => {
|
| 304 |
console.log('connectionstatechange', peerConnection.connectionState);
|
| 305 |
+
if (peerConnection.connectionState === 'connected') {
|
| 306 |
+
clearTimeout(timeoutId);
|
| 307 |
+
const toast = document.getElementById('error-toast');
|
| 308 |
+
toast.style.display = 'none';
|
| 309 |
+
}
|
| 310 |
updateButtonState();
|
| 311 |
});
|
| 312 |
|
|
|
|
| 363 |
appendTranscript(event.data);
|
| 364 |
});
|
| 365 |
} catch (err) {
|
| 366 |
+
clearTimeout(timeoutId);
|
| 367 |
console.error('Error setting up WebRTC:', err);
|
| 368 |
showError('Failed to establish connection. Please try again.');
|
| 369 |
stop();
|