@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.mjs
CHANGED
|
@@ -3093,7 +3093,7 @@ var _Wav2Vec2Inference = class _Wav2Vec2Inference {
|
|
|
3093
3093
|
audio = audioSamplesCopy.slice(0, 16e3);
|
|
3094
3094
|
}
|
|
3095
3095
|
const identity = new Float32Array(this.numIdentityClasses);
|
|
3096
|
-
identity[Math.min(identityIndex, this.numIdentityClasses - 1)] = 1;
|
|
3096
|
+
identity[Math.max(0, Math.min(identityIndex, this.numIdentityClasses - 1))] = 1;
|
|
3097
3097
|
const audioCopy = new Float32Array(audio);
|
|
3098
3098
|
const identityCopy = new Float32Array(identity);
|
|
3099
3099
|
const feeds = {
|
|
@@ -9105,11 +9105,14 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9105
9105
|
return new Promise((resolve) => {
|
|
9106
9106
|
const timeout = setTimeout(() => resolve(false), 5e3);
|
|
9107
9107
|
const handler = (event) => {
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9108
|
+
try {
|
|
9109
|
+
const data = JSON.parse(event.data);
|
|
9110
|
+
if (data.type === "pong") {
|
|
9111
|
+
clearTimeout(timeout);
|
|
9112
|
+
this.ws?.removeEventListener("message", handler);
|
|
9113
|
+
resolve(true);
|
|
9114
|
+
}
|
|
9115
|
+
} catch {
|
|
9113
9116
|
}
|
|
9114
9117
|
};
|
|
9115
9118
|
this.ws?.addEventListener("message", handler);
|
|
@@ -9235,7 +9238,10 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9235
9238
|
}));
|
|
9236
9239
|
};
|
|
9237
9240
|
this.ws.onmessage = (event) => {
|
|
9238
|
-
|
|
9241
|
+
try {
|
|
9242
|
+
this.handleAgentCoreMessage(JSON.parse(event.data));
|
|
9243
|
+
} catch {
|
|
9244
|
+
}
|
|
9239
9245
|
};
|
|
9240
9246
|
this.ws.onerror = () => {
|
|
9241
9247
|
reject(new Error("WebSocket connection failed"));
|
|
@@ -9247,14 +9253,17 @@ var AgentCoreAdapter = class extends EventEmitter {
|
|
|
9247
9253
|
reject(new Error("Auth timeout"));
|
|
9248
9254
|
}, 1e4);
|
|
9249
9255
|
const authHandler = (event) => {
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9256
|
+
try {
|
|
9257
|
+
const data = JSON.parse(event.data);
|
|
9258
|
+
if (data.type === "auth_success") {
|
|
9259
|
+
clearTimeout(authTimeout);
|
|
9260
|
+
this.ws?.removeEventListener("message", authHandler);
|
|
9261
|
+
resolve();
|
|
9262
|
+
} else if (data.type === "auth_failed") {
|
|
9263
|
+
clearTimeout(authTimeout);
|
|
9264
|
+
reject(new Error(data.message));
|
|
9265
|
+
}
|
|
9266
|
+
} catch {
|
|
9258
9267
|
}
|
|
9259
9268
|
};
|
|
9260
9269
|
this.ws.addEventListener("message", authHandler);
|
|
@@ -10063,20 +10072,6 @@ var InterruptionHandler = class extends EventEmitter {
|
|
|
10063
10072
|
this.onSilenceDetected();
|
|
10064
10073
|
}
|
|
10065
10074
|
}
|
|
10066
|
-
/**
|
|
10067
|
-
* @deprecated Use processVADResult() instead. This method uses naive RMS detection.
|
|
10068
|
-
* Process audio samples for VAD (legacy - uses simple RMS)
|
|
10069
|
-
*/
|
|
10070
|
-
processAudio(samples) {
|
|
10071
|
-
if (!this.config.enabled) return;
|
|
10072
|
-
const rms = this.calculateRMS(samples);
|
|
10073
|
-
const vadProbability = Math.min(rms / 0.02, 1);
|
|
10074
|
-
if (vadProbability > this.config.vadThreshold) {
|
|
10075
|
-
this.onSpeechDetected(rms);
|
|
10076
|
-
} else {
|
|
10077
|
-
this.onSilenceDetected();
|
|
10078
|
-
}
|
|
10079
|
-
}
|
|
10080
10075
|
/**
|
|
10081
10076
|
* Notify that AI started speaking
|
|
10082
10077
|
*/
|
|
@@ -10121,15 +10116,6 @@ var InterruptionHandler = class extends EventEmitter {
|
|
|
10121
10116
|
};
|
|
10122
10117
|
}
|
|
10123
10118
|
// ==================== Private Methods ====================
|
|
10124
|
-
calculateRMS(samples) {
|
|
10125
|
-
let sum = 0;
|
|
10126
|
-
const scale = samples instanceof Int16Array ? 32768 : 1;
|
|
10127
|
-
for (let i = 0; i < samples.length; i++) {
|
|
10128
|
-
const sample = samples[i] / scale;
|
|
10129
|
-
sum += sample * sample;
|
|
10130
|
-
}
|
|
10131
|
-
return Math.sqrt(sum / samples.length);
|
|
10132
|
-
}
|
|
10133
10119
|
onSpeechDetected(rms) {
|
|
10134
10120
|
const now = Date.now();
|
|
10135
10121
|
this.lastSpeechTime = now;
|