@mclean-capital/neura 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70517,6 +70517,13 @@ function attachWebSocket(httpServer2, services2) {
70517
70517
  session?.sendAudio(chunk);
70518
70518
  }
70519
70519
  }
70520
+ if (pendingActivationAudio.length > 0) {
70521
+ const chunks = pendingActivationAudio;
70522
+ pendingActivationAudio = [];
70523
+ for (const chunk of chunks) {
70524
+ session?.sendAudio(chunk);
70525
+ }
70526
+ }
70520
70527
  if (pendingText.length > 0) {
70521
70528
  const texts = pendingText;
70522
70529
  pendingText = [];
@@ -70547,6 +70554,8 @@ function attachWebSocket(httpServer2, services2) {
70547
70554
  };
70548
70555
  let pendingWakeAudio = null;
70549
70556
  let pendingText = [];
70557
+ let pendingActivationAudio = [];
70558
+ const MAX_PENDING_ACTIVATION_AUDIO = 100;
70550
70559
  async function activateVoiceSession(wakeTranscript) {
70551
70560
  if (connectionClosed || session) return;
70552
70561
  log15.info("activating voice session", { wakeTranscript });
@@ -70579,6 +70588,7 @@ function attachWebSocket(httpServer2, services2) {
70579
70588
  function deactivateVoiceSession() {
70580
70589
  log15.info("deactivating voice session");
70581
70590
  pendingWakeAudio = null;
70591
+ pendingActivationAudio = [];
70582
70592
  pendingText = [];
70583
70593
  costTracker.stopInterval();
70584
70594
  triggerExtraction();
@@ -70637,11 +70647,18 @@ function attachWebSocket(httpServer2, services2) {
70637
70647
  const msg = JSON.parse(raw.toString());
70638
70648
  switch (msg.type) {
70639
70649
  case "audio":
70640
- if (presence.state === "active" && session) {
70641
- resetIdleTimer();
70642
- presence.resetIdleTimer();
70643
- extractionTriggered = false;
70644
- session.sendAudio(msg.data);
70650
+ if (presence.state === "active") {
70651
+ if (session) {
70652
+ resetIdleTimer();
70653
+ presence.resetIdleTimer();
70654
+ extractionTriggered = false;
70655
+ session.sendAudio(msg.data);
70656
+ } else {
70657
+ pendingActivationAudio.push(msg.data);
70658
+ if (pendingActivationAudio.length > MAX_PENDING_ACTIVATION_AUDIO) {
70659
+ pendingActivationAudio.shift();
70660
+ }
70661
+ }
70645
70662
  } else if (presence.state === "passive") {
70646
70663
  if (wakeDetector) {
70647
70664
  wakeDetector.feedAudio(msg.data);