@omote/core 0.4.6 → 0.4.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.
- package/dist/index.d.mts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +24 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3992,11 +3992,6 @@ declare class InterruptionHandler extends EventEmitter<InterruptionEvents> {
|
|
|
3992
3992
|
* @param audioEnergy - Optional RMS energy for logging (default: 0)
|
|
3993
3993
|
*/
|
|
3994
3994
|
processVADResult(vadProbability: number, audioEnergy?: number): void;
|
|
3995
|
-
/**
|
|
3996
|
-
* @deprecated Use processVADResult() instead. This method uses naive RMS detection.
|
|
3997
|
-
* Process audio samples for VAD (legacy - uses simple RMS)
|
|
3998
|
-
*/
|
|
3999
|
-
processAudio(samples: Float32Array | Int16Array): void;
|
|
4000
3995
|
/**
|
|
4001
3996
|
* Notify that AI started speaking
|
|
4002
3997
|
*/
|
|
@@ -4020,7 +4015,6 @@ declare class InterruptionHandler extends EventEmitter<InterruptionEvents> {
|
|
|
4020
4015
|
isSpeaking: boolean;
|
|
4021
4016
|
speechDurationMs: number;
|
|
4022
4017
|
};
|
|
4023
|
-
private calculateRMS;
|
|
4024
4018
|
private onSpeechDetected;
|
|
4025
4019
|
private onSilenceDetected;
|
|
4026
4020
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3992,11 +3992,6 @@ declare class InterruptionHandler extends EventEmitter<InterruptionEvents> {
|
|
|
3992
3992
|
* @param audioEnergy - Optional RMS energy for logging (default: 0)
|
|
3993
3993
|
*/
|
|
3994
3994
|
processVADResult(vadProbability: number, audioEnergy?: number): void;
|
|
3995
|
-
/**
|
|
3996
|
-
* @deprecated Use processVADResult() instead. This method uses naive RMS detection.
|
|
3997
|
-
* Process audio samples for VAD (legacy - uses simple RMS)
|
|
3998
|
-
*/
|
|
3999
|
-
processAudio(samples: Float32Array | Int16Array): void;
|
|
4000
3995
|
/**
|
|
4001
3996
|
* Notify that AI started speaking
|
|
4002
3997
|
*/
|
|
@@ -4020,7 +4015,6 @@ declare class InterruptionHandler extends EventEmitter<InterruptionEvents> {
|
|
|
4020
4015
|
isSpeaking: boolean;
|
|
4021
4016
|
speechDurationMs: number;
|
|
4022
4017
|
};
|
|
4023
|
-
private calculateRMS;
|
|
4024
4018
|
private onSpeechDetected;
|
|
4025
4019
|
private onSilenceDetected;
|
|
4026
4020
|
}
|
package/dist/index.js
CHANGED
|
@@ -3521,7 +3521,7 @@ var _Wav2Vec2Inference = class _Wav2Vec2Inference {
|
|
|
3521
3521
|
audio = audioSamplesCopy.slice(0, 16e3);
|
|
3522
3522
|
}
|
|
3523
3523
|
const identity = new Float32Array(this.numIdentityClasses);
|
|
3524
|
-
identity[Math.min(identityIndex, this.numIdentityClasses - 1)] = 1;
|
|
3524
|
+
identity[Math.max(0, Math.min(identityIndex, this.numIdentityClasses - 1))] = 1;
|
|
3525
3525
|
const audioCopy = new Float32Array(audio);
|
|
3526
3526
|
const identityCopy = new Float32Array(identity);
|
|
3527
3527
|
const feeds = {
|
|
@@ -9533,11 +9533,14 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9533
9533
|
return new Promise((resolve) => {
|
|
9534
9534
|
const timeout = setTimeout(() => resolve(false), 5e3);
|
|
9535
9535
|
const handler = (event) => {
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9536
|
+
try {
|
|
9537
|
+
const data = JSON.parse(event.data);
|
|
9538
|
+
if (data.type === "pong") {
|
|
9539
|
+
clearTimeout(timeout);
|
|
9540
|
+
this.ws?.removeEventListener("message", handler);
|
|
9541
|
+
resolve(true);
|
|
9542
|
+
}
|
|
9543
|
+
} catch {
|
|
9541
9544
|
}
|
|
9542
9545
|
};
|
|
9543
9546
|
this.ws?.addEventListener("message", handler);
|
|
@@ -9663,7 +9666,10 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9663
9666
|
}));
|
|
9664
9667
|
};
|
|
9665
9668
|
this.ws.onmessage = (event) => {
|
|
9666
|
-
|
|
9669
|
+
try {
|
|
9670
|
+
this.handleAgentCoreMessage(JSON.parse(event.data));
|
|
9671
|
+
} catch {
|
|
9672
|
+
}
|
|
9667
9673
|
};
|
|
9668
9674
|
this.ws.onerror = () => {
|
|
9669
9675
|
reject(new Error("WebSocket connection failed"));
|
|
@@ -9675,14 +9681,17 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9675
9681
|
reject(new Error("Auth timeout"));
|
|
9676
9682
|
}, 1e4);
|
|
9677
9683
|
const authHandler = (event) => {
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9684
|
+
try {
|
|
9685
|
+
const data = JSON.parse(event.data);
|
|
9686
|
+
if (data.type === "auth_success") {
|
|
9687
|
+
clearTimeout(authTimeout);
|
|
9688
|
+
this.ws?.removeEventListener("message", authHandler);
|
|
9689
|
+
resolve();
|
|
9690
|
+
} else if (data.type === "auth_failed") {
|
|
9691
|
+
clearTimeout(authTimeout);
|
|
9692
|
+
reject(new Error(data.message));
|
|
9693
|
+
}
|
|
9694
|
+
} catch {
|
|
9686
9695
|
}
|
|
9687
9696
|
};
|
|
9688
9697
|
this.ws.addEventListener("message", authHandler);
|
|
@@ -10491,20 +10500,6 @@ var InterruptionHandler = class extends EventEmitter {
|
|
|
10491
10500
|
this.onSilenceDetected();
|
|
10492
10501
|
}
|
|
10493
10502
|
}
|
|
10494
|
-
/**
|
|
10495
|
-
* @deprecated Use processVADResult() instead. This method uses naive RMS detection.
|
|
10496
|
-
* Process audio samples for VAD (legacy - uses simple RMS)
|
|
10497
|
-
*/
|
|
10498
|
-
processAudio(samples) {
|
|
10499
|
-
if (!this.config.enabled) return;
|
|
10500
|
-
const rms = this.calculateRMS(samples);
|
|
10501
|
-
const vadProbability = Math.min(rms / 0.02, 1);
|
|
10502
|
-
if (vadProbability > this.config.vadThreshold) {
|
|
10503
|
-
this.onSpeechDetected(rms);
|
|
10504
|
-
} else {
|
|
10505
|
-
this.onSilenceDetected();
|
|
10506
|
-
}
|
|
10507
|
-
}
|
|
10508
10503
|
/**
|
|
10509
10504
|
* Notify that AI started speaking
|
|
10510
10505
|
*/
|
|
@@ -10549,15 +10544,6 @@ var InterruptionHandler = class extends EventEmitter {
|
|
|
10549
10544
|
};
|
|
10550
10545
|
}
|
|
10551
10546
|
// ==================== Private Methods ====================
|
|
10552
|
-
calculateRMS(samples) {
|
|
10553
|
-
let sum = 0;
|
|
10554
|
-
const scale = samples instanceof Int16Array ? 32768 : 1;
|
|
10555
|
-
for (let i = 0; i < samples.length; i++) {
|
|
10556
|
-
const sample = samples[i] / scale;
|
|
10557
|
-
sum += sample * sample;
|
|
10558
|
-
}
|
|
10559
|
-
return Math.sqrt(sum / samples.length);
|
|
10560
|
-
}
|
|
10561
10547
|
onSpeechDetected(rms) {
|
|
10562
10548
|
const now = Date.now();
|
|
10563
10549
|
this.lastSpeechTime = now;
|