@mclean-capital/neura 2.2.3 → 2.2.4
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.
- package/core/server.bundled.mjs +12 -4
- package/core/server.bundled.mjs.map +2 -2
- package/core/version.txt +1 -1
- package/package.json +1 -1
package/core/server.bundled.mjs
CHANGED
|
@@ -69982,7 +69982,7 @@ var FRAME_SIZE_16K = 1280;
|
|
|
69982
69982
|
var INFERENCE_STRIDE = 4;
|
|
69983
69983
|
var ENERGY_THRESHOLD = 1e-3;
|
|
69984
69984
|
var DEBOUNCE_MS = 2e3;
|
|
69985
|
-
var
|
|
69985
|
+
var MAX_REPLAY_BYTES = 24e3 * 2 * 4;
|
|
69986
69986
|
var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
69987
69987
|
config;
|
|
69988
69988
|
threshold;
|
|
@@ -70002,8 +70002,11 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
70002
70002
|
totalSamplesWritten = 0;
|
|
70003
70003
|
// Partial frame accumulator (resampled 16kHz samples)
|
|
70004
70004
|
accumulator = new Float32Array(0);
|
|
70005
|
-
// Replay buffer: original base64 chunks for Grok
|
|
70005
|
+
// Replay buffer: original base64 chunks for Grok, evicted by total byte
|
|
70006
|
+
// count (not chunk count) so the buffer duration is consistent regardless
|
|
70007
|
+
// of the mic's chunk size.
|
|
70006
70008
|
replayChunks = [];
|
|
70009
|
+
replayBytes = 0;
|
|
70007
70010
|
// Inference gating
|
|
70008
70011
|
frameCounter = 0;
|
|
70009
70012
|
lastDetectionTime = 0;
|
|
@@ -70062,8 +70065,10 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
70062
70065
|
}
|
|
70063
70066
|
const resampled = resample24kTo16k(float32);
|
|
70064
70067
|
this.replayChunks.push(base64Pcm);
|
|
70065
|
-
|
|
70066
|
-
|
|
70068
|
+
this.replayBytes += raw.byteLength;
|
|
70069
|
+
while (this.replayBytes > MAX_REPLAY_BYTES && this.replayChunks.length > 1) {
|
|
70070
|
+
const evicted = this.replayChunks.shift();
|
|
70071
|
+
this.replayBytes -= Buffer.from(evicted, "base64").byteLength;
|
|
70067
70072
|
}
|
|
70068
70073
|
const combined = new Float32Array(this.accumulator.length + resampled.length);
|
|
70069
70074
|
combined.set(this.accumulator);
|
|
@@ -70104,6 +70109,7 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
70104
70109
|
this.closed = true;
|
|
70105
70110
|
this.accumulator = new Float32Array(0);
|
|
70106
70111
|
this.replayChunks.length = 0;
|
|
70112
|
+
this.replayBytes = 0;
|
|
70107
70113
|
}
|
|
70108
70114
|
/**
|
|
70109
70115
|
* Clear all buffered audio and inference state without releasing the
|
|
@@ -70130,6 +70136,7 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
70130
70136
|
this.writePos = 0;
|
|
70131
70137
|
this.totalSamplesWritten = 0;
|
|
70132
70138
|
this.replayChunks.length = 0;
|
|
70139
|
+
this.replayBytes = 0;
|
|
70133
70140
|
this.frameCounter = 0;
|
|
70134
70141
|
this.lastDetectionTime = 0;
|
|
70135
70142
|
}
|
|
@@ -70152,6 +70159,7 @@ var OnnxWakeDetector = class _OnnxWakeDetector {
|
|
|
70152
70159
|
this.lastDetectionTime = Date.now();
|
|
70153
70160
|
const chunks = [...this.replayChunks];
|
|
70154
70161
|
this.replayChunks.length = 0;
|
|
70162
|
+
this.replayBytes = 0;
|
|
70155
70163
|
this.config.onWake(chunks);
|
|
70156
70164
|
}
|
|
70157
70165
|
} catch (err) {
|