atlury commited on
Commit
67af410
·
verified ·
1 Parent(s): 915dd7f

Update index.backup5.html

Browse files
Files changed (1) hide show
  1. index.backup5.html +61 -1
index.backup5.html CHANGED
@@ -404,4 +404,64 @@
404
  });
405
 
406
  await myvad.start();
407
- startButton.textContent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  });
405
 
406
  await myvad.start();
407
+ startButton.textContent = 'End Call';
408
+ isListening = true;
409
+ addLog('System: Listening...');
410
+ } catch (error) {
411
+ console.error('Error starting voice activity:', error);
412
+ addLog(`System: Error starting voice detection: ${error.message}`);
413
+ }
414
+ }
415
+
416
+ async function stopListening() {
417
+ if (myvad) {
418
+ try {
419
+ await myvad.destroy();
420
+ } catch (error) {
421
+ console.error('Error stopping voice activity:', error);
422
+ }
423
+ myvad = null;
424
+ }
425
+ if (microphoneStream) {
426
+ microphoneStream.getTracks().forEach(track => track.stop());
427
+ microphoneStream = null;
428
+ }
429
+ if (audioContext) {
430
+ await audioContext.close();
431
+ audioContext = null;
432
+ }
433
+ if (localVideo) {
434
+ localVideo.srcObject = null;
435
+ }
436
+ if (remoteVideo) {
437
+ remoteVideo.srcObject = null;
438
+ }
439
+ if (rtcConnection) {
440
+ rtcConnection.close();
441
+ rtcConnection = null;
442
+ }
443
+ if (rtcLoopbackConnection) {
444
+ rtcLoopbackConnection.close();
445
+ rtcLoopbackConnection = null;
446
+ }
447
+ loopbackStream = new MediaStream();
448
+ stopCurrentAudio();
449
+ startButton.textContent = 'Begin Call';
450
+ isListening = false;
451
+ addLog('System: Stopped listening.');
452
+ cancelAnimationFrame(animationId);
453
+ addLog('System: Microphone closed');
454
+ }
455
+
456
+ startButton.addEventListener('click', toggleListening);
457
+ clearLogsButton.addEventListener('click', () => {
458
+ logsDiv.innerHTML = '';
459
+ });
460
+
461
+ createVisualizer();
462
+ initializePipelines();
463
+ </script>
464
+ </body>
465
+ </html>
466
+
467
+