OllieCentral commited on
Commit
db121d5
·
verified ·
1 Parent(s): f0998d6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +30 -6
index.html CHANGED
@@ -243,7 +243,7 @@
243
  </main>
244
 
245
  <footer class="text-center text-sm opacity-50 mt-8">
246
- <p>Powered by <span class="glow-text text-blue-400">Nebula AI</span> | v1.2.4</p>
247
  </footer>
248
  </div>
249
 
@@ -392,17 +392,29 @@
392
  recognition.continuous = true;
393
  recognition.interimResults = false;
394
 
395
- recognition.onresult = async (event) => {
396
  const transcript = event.results[event.results.length - 1][0].transcript.trim();
397
  if (transcript && transcript !== lastTranscript) {
398
- $('#lastObjection').textContent = transcript;
399
  lastTranscript = transcript;
400
- await generateResponse(transcript);
 
 
 
 
 
 
401
  }
402
  };
403
 
404
  recognition.onerror = (event) => {
405
  console.error('Speech recognition error:', event.error);
 
 
 
 
 
 
 
406
  if(event.error === 'not-allowed' || event.error === 'service-not-allowed') {
407
  showCustomAlert('Microphone access was denied. Please allow microphone access in your browser settings to use this feature.');
408
  stopListening();
@@ -413,7 +425,12 @@
413
 
414
  recognition.onend = () => {
415
  if (isListening) {
416
- recognition.start();
 
 
 
 
 
417
  }
418
  };
419
  }
@@ -454,7 +471,8 @@
454
  const replyElement = $('#reply');
455
  replyElement.textContent = 'Thinking...';
456
  replyElement.classList.add('pulse');
457
- uiStateManager.update(uiStateManager.states.PROCESSING);
 
458
 
459
  try {
460
  const reply = await generateApiResponse(text, appState.systemPrompt);
@@ -462,11 +480,17 @@
462
  } catch (error) {
463
  console.error('Error generating response:', error);
464
  replyElement.textContent = `❌ Error: ${error.message}`;
 
465
  uiStateManager.update(uiStateManager.states.ERROR);
 
 
 
466
  } finally {
467
  replyElement.classList.remove('pulse');
 
468
  if (isListening) {
469
  uiStateManager.update(uiStateManager.states.LISTENING);
 
470
  } else {
471
  uiStateManager.update(uiStateManager.states.READY);
472
  }
 
243
  </main>
244
 
245
  <footer class="text-center text-sm opacity-50 mt-8">
246
+ <p>Powered by <span class="glow-text text-blue-400">Nebula AI</span> | v1.2.5</p>
247
  </footer>
248
  </div>
249
 
 
392
  recognition.continuous = true;
393
  recognition.interimResults = false;
394
 
395
+ recognition.onresult = (event) => {
396
  const transcript = event.results[event.results.length - 1][0].transcript.trim();
397
  if (transcript && transcript !== lastTranscript) {
 
398
  lastTranscript = transcript;
399
+ $('#lastObjection').textContent = transcript;
400
+
401
+ // Force a restart to ensure continuous listening
402
+ recognition.abort();
403
+
404
+ // Process the response in the background
405
+ generateResponse(transcript);
406
  }
407
  };
408
 
409
  recognition.onerror = (event) => {
410
  console.error('Speech recognition error:', event.error);
411
+ if (event.error === 'no-speech') {
412
+ // Ignore no-speech errors and just restart
413
+ if (isListening) {
414
+ recognition.start();
415
+ }
416
+ return;
417
+ }
418
  if(event.error === 'not-allowed' || event.error === 'service-not-allowed') {
419
  showCustomAlert('Microphone access was denied. Please allow microphone access in your browser settings to use this feature.');
420
  stopListening();
 
425
 
426
  recognition.onend = () => {
427
  if (isListening) {
428
+ console.log('Recognition ended, restarting...');
429
+ try {
430
+ recognition.start();
431
+ } catch(e) {
432
+ console.error("Error restarting recognition:", e);
433
+ }
434
  }
435
  };
436
  }
 
471
  const replyElement = $('#reply');
472
  replyElement.textContent = 'Thinking...';
473
  replyElement.classList.add('pulse');
474
+ // We don't set UI state to processing to keep the "Listening" state active
475
+ // uiStateManager.update(uiStateManager.states.PROCESSING);
476
 
477
  try {
478
  const reply = await generateApiResponse(text, appState.systemPrompt);
 
480
  } catch (error) {
481
  console.error('Error generating response:', error);
482
  replyElement.textContent = `❌ Error: ${error.message}`;
483
+ // Briefly show error state before returning to listening
484
  uiStateManager.update(uiStateManager.states.ERROR);
485
+ setTimeout(() => {
486
+ if(isListening) uiStateManager.update(uiStateManager.states.LISTENING);
487
+ }, 2000);
488
  } finally {
489
  replyElement.classList.remove('pulse');
490
+ // Ensure UI is back to listening if it's supposed to be
491
  if (isListening) {
492
  uiStateManager.update(uiStateManager.states.LISTENING);
493
+ $('#lastObjection').textContent = 'Listening for next phrase...';
494
  } else {
495
  uiStateManager.update(uiStateManager.states.READY);
496
  }