Spaces:
Running
Running
Update index.html
Browse files- index.html +19 -9
index.html
CHANGED
|
@@ -333,17 +333,27 @@
|
|
| 333 |
|
| 334 |
async function stopListening() {
|
| 335 |
if (myvad) {
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
|
|
|
| 339 |
}
|
| 340 |
-
|
| 341 |
-
startButton.textContent = 'Begin Call';
|
| 342 |
-
isListening = false;
|
| 343 |
-
addLog('System: Stopped listening.');
|
| 344 |
-
cancelAnimationFrame(animationId);
|
| 345 |
-
addLog('System: Microphone closed');
|
| 346 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
}
|
| 348 |
|
| 349 |
startButton.addEventListener('click', toggleListening);
|
|
|
|
| 333 |
|
| 334 |
async function stopListening() {
|
| 335 |
if (myvad) {
|
| 336 |
+
try {
|
| 337 |
+
await myvad.destroy();
|
| 338 |
+
} catch (error) {
|
| 339 |
+
console.error('Error stopping VAD:', error);
|
| 340 |
}
|
| 341 |
+
myvad = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
}
|
| 343 |
+
if (microphoneStream) {
|
| 344 |
+
microphoneStream.getTracks().forEach(track => track.stop());
|
| 345 |
+
microphoneStream = null;
|
| 346 |
+
}
|
| 347 |
+
if (audioContext) {
|
| 348 |
+
await audioContext.close();
|
| 349 |
+
audioContext = null;
|
| 350 |
+
}
|
| 351 |
+
stopCurrentAudio();
|
| 352 |
+
startButton.textContent = 'Begin Call';
|
| 353 |
+
isListening = false;
|
| 354 |
+
addLog('System: Stopped listening.');
|
| 355 |
+
cancelAnimationFrame(animationId);
|
| 356 |
+
addLog('System: Microphone closed');
|
| 357 |
}
|
| 358 |
|
| 359 |
startButton.addEventListener('click', toggleListening);
|