@livekit/agents 1.0.36-dev.0 → 1.0.37
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.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/inference/utils.cjs +2 -15
- package/dist/inference/utils.cjs.map +1 -1
- package/dist/inference/utils.d.cts +0 -1
- package/dist/inference/utils.d.ts +0 -1
- package/dist/inference/utils.d.ts.map +1 -1
- package/dist/inference/utils.js +1 -13
- package/dist/inference/utils.js.map +1 -1
- package/dist/stream/stream_channel.cjs +0 -3
- package/dist/stream/stream_channel.cjs.map +1 -1
- package/dist/stream/stream_channel.d.cts +2 -3
- package/dist/stream/stream_channel.d.ts +2 -3
- package/dist/stream/stream_channel.d.ts.map +1 -1
- package/dist/stream/stream_channel.js +0 -3
- package/dist/stream/stream_channel.js.map +1 -1
- package/dist/telemetry/trace_types.cjs +0 -15
- package/dist/telemetry/trace_types.cjs.map +1 -1
- package/dist/telemetry/trace_types.d.cts +0 -5
- package/dist/telemetry/trace_types.d.ts +0 -5
- package/dist/telemetry/trace_types.d.ts.map +1 -1
- package/dist/telemetry/trace_types.js +0 -10
- package/dist/telemetry/trace_types.js.map +1 -1
- package/dist/voice/agent_activity.cjs +19 -68
- package/dist/voice/agent_activity.cjs.map +1 -1
- package/dist/voice/agent_activity.d.cts +0 -14
- package/dist/voice/agent_activity.d.ts +0 -14
- package/dist/voice/agent_activity.d.ts.map +1 -1
- package/dist/voice/agent_activity.js +19 -68
- package/dist/voice/agent_activity.js.map +1 -1
- package/dist/voice/agent_session.cjs +65 -37
- package/dist/voice/agent_session.cjs.map +1 -1
- package/dist/voice/agent_session.d.cts +25 -4
- package/dist/voice/agent_session.d.ts +25 -4
- package/dist/voice/agent_session.d.ts.map +1 -1
- package/dist/voice/agent_session.js +65 -37
- package/dist/voice/agent_session.js.map +1 -1
- package/dist/voice/audio_recognition.cjs +2 -124
- package/dist/voice/audio_recognition.cjs.map +1 -1
- package/dist/voice/audio_recognition.d.cts +1 -32
- package/dist/voice/audio_recognition.d.ts +1 -32
- package/dist/voice/audio_recognition.d.ts.map +1 -1
- package/dist/voice/audio_recognition.js +2 -127
- package/dist/voice/audio_recognition.js.map +1 -1
- package/dist/voice/index.cjs +14 -1
- package/dist/voice/index.cjs.map +1 -1
- package/dist/voice/index.d.cts +1 -0
- package/dist/voice/index.d.ts +1 -0
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +3 -1
- package/dist/voice/index.js.map +1 -1
- package/dist/voice/room_io/room_io.cjs +1 -0
- package/dist/voice/room_io/room_io.cjs.map +1 -1
- package/dist/voice/room_io/room_io.d.ts.map +1 -1
- package/dist/voice/room_io/room_io.js +1 -0
- package/dist/voice/room_io/room_io.js.map +1 -1
- package/dist/voice/speech_handle.cjs +12 -3
- package/dist/voice/speech_handle.cjs.map +1 -1
- package/dist/voice/speech_handle.d.cts +12 -2
- package/dist/voice/speech_handle.d.ts +12 -2
- package/dist/voice/speech_handle.d.ts.map +1 -1
- package/dist/voice/speech_handle.js +10 -2
- package/dist/voice/speech_handle.js.map +1 -1
- package/dist/voice/testing/index.cjs +54 -0
- package/dist/voice/testing/index.cjs.map +1 -0
- package/dist/voice/testing/index.d.cts +20 -0
- package/dist/voice/testing/index.d.ts +20 -0
- package/dist/voice/testing/index.d.ts.map +1 -0
- package/dist/voice/testing/index.js +33 -0
- package/dist/voice/testing/index.js.map +1 -0
- package/dist/voice/testing/run_result.cjs +766 -0
- package/dist/voice/testing/run_result.cjs.map +1 -0
- package/dist/voice/testing/run_result.d.cts +374 -0
- package/dist/voice/testing/run_result.d.ts +374 -0
- package/dist/voice/testing/run_result.d.ts.map +1 -0
- package/dist/voice/testing/run_result.js +739 -0
- package/dist/voice/testing/run_result.js.map +1 -0
- package/dist/{inference/interruption/index.cjs → voice/testing/types.cjs} +24 -12
- package/dist/voice/testing/types.cjs.map +1 -0
- package/dist/voice/testing/types.d.cts +83 -0
- package/dist/voice/testing/types.d.ts +83 -0
- package/dist/voice/testing/types.d.ts.map +1 -0
- package/dist/voice/testing/types.js +19 -0
- package/dist/voice/testing/types.js.map +1 -0
- package/package.json +3 -4
- package/src/index.ts +0 -2
- package/src/inference/utils.ts +0 -15
- package/src/stream/stream_channel.ts +2 -6
- package/src/telemetry/trace_types.ts +0 -7
- package/src/voice/agent_activity.ts +24 -83
- package/src/voice/agent_session.ts +74 -49
- package/src/voice/audio_recognition.ts +1 -161
- package/src/voice/index.ts +1 -0
- package/src/voice/room_io/room_io.ts +1 -0
- package/src/voice/speech_handle.ts +24 -4
- package/src/voice/testing/index.ts +50 -0
- package/src/voice/testing/run_result.ts +937 -0
- package/src/voice/testing/types.ts +118 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs +0 -152
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs.map +0 -1
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.cts +0 -50
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts +0 -50
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts.map +0 -1
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js +0 -125
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js.map +0 -1
- package/dist/inference/interruption/InterruptionStream.cjs +0 -310
- package/dist/inference/interruption/InterruptionStream.cjs.map +0 -1
- package/dist/inference/interruption/InterruptionStream.d.cts +0 -57
- package/dist/inference/interruption/InterruptionStream.d.ts +0 -57
- package/dist/inference/interruption/InterruptionStream.d.ts.map +0 -1
- package/dist/inference/interruption/InterruptionStream.js +0 -288
- package/dist/inference/interruption/InterruptionStream.js.map +0 -1
- package/dist/inference/interruption/defaults.cjs +0 -76
- package/dist/inference/interruption/defaults.cjs.map +0 -1
- package/dist/inference/interruption/defaults.d.cts +0 -14
- package/dist/inference/interruption/defaults.d.ts +0 -14
- package/dist/inference/interruption/defaults.d.ts.map +0 -1
- package/dist/inference/interruption/defaults.js +0 -42
- package/dist/inference/interruption/defaults.js.map +0 -1
- package/dist/inference/interruption/errors.cjs +0 -2
- package/dist/inference/interruption/errors.cjs.map +0 -1
- package/dist/inference/interruption/errors.d.cts +0 -2
- package/dist/inference/interruption/errors.d.ts +0 -2
- package/dist/inference/interruption/errors.d.ts.map +0 -1
- package/dist/inference/interruption/errors.js +0 -1
- package/dist/inference/interruption/errors.js.map +0 -1
- package/dist/inference/interruption/http_transport.cjs +0 -57
- package/dist/inference/interruption/http_transport.cjs.map +0 -1
- package/dist/inference/interruption/http_transport.d.cts +0 -23
- package/dist/inference/interruption/http_transport.d.ts +0 -23
- package/dist/inference/interruption/http_transport.d.ts.map +0 -1
- package/dist/inference/interruption/http_transport.js +0 -33
- package/dist/inference/interruption/http_transport.js.map +0 -1
- package/dist/inference/interruption/index.cjs.map +0 -1
- package/dist/inference/interruption/index.d.cts +0 -5
- package/dist/inference/interruption/index.d.ts +0 -5
- package/dist/inference/interruption/index.d.ts.map +0 -1
- package/dist/inference/interruption/index.js +0 -7
- package/dist/inference/interruption/index.js.map +0 -1
- package/dist/inference/interruption/interruption.cjs +0 -85
- package/dist/inference/interruption/interruption.cjs.map +0 -1
- package/dist/inference/interruption/interruption.d.cts +0 -48
- package/dist/inference/interruption/interruption.d.ts +0 -48
- package/dist/inference/interruption/interruption.d.ts.map +0 -1
- package/dist/inference/interruption/interruption.js +0 -59
- package/dist/inference/interruption/interruption.js.map +0 -1
- package/dist/inference/utils.test.cjs +0 -20
- package/dist/inference/utils.test.cjs.map +0 -1
- package/dist/inference/utils.test.js +0 -19
- package/dist/inference/utils.test.js.map +0 -1
- package/dist/utils/ws_transport.cjs +0 -51
- package/dist/utils/ws_transport.cjs.map +0 -1
- package/dist/utils/ws_transport.d.cts +0 -9
- package/dist/utils/ws_transport.d.ts +0 -9
- package/dist/utils/ws_transport.d.ts.map +0 -1
- package/dist/utils/ws_transport.js +0 -17
- package/dist/utils/ws_transport.js.map +0 -1
- package/dist/utils/ws_transport.test.cjs +0 -212
- package/dist/utils/ws_transport.test.cjs.map +0 -1
- package/dist/utils/ws_transport.test.js +0 -211
- package/dist/utils/ws_transport.test.js.map +0 -1
- package/src/inference/interruption/AdaptiveInterruptionDetector.ts +0 -166
- package/src/inference/interruption/InterruptionStream.ts +0 -397
- package/src/inference/interruption/defaults.ts +0 -33
- package/src/inference/interruption/errors.ts +0 -0
- package/src/inference/interruption/http_transport.ts +0 -61
- package/src/inference/interruption/index.ts +0 -4
- package/src/inference/interruption/interruption.ts +0 -88
- package/src/inference/utils.test.ts +0 -31
- package/src/utils/ws_transport.test.ts +0 -282
- package/src/utils/ws_transport.ts +0 -22
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ofetch } from "ofetch";
|
|
2
|
-
async function predictHTTP(data, predictOptions, options) {
|
|
3
|
-
const createdAt = performance.now();
|
|
4
|
-
const url = new URL(`/bargein`, options.baseUrl);
|
|
5
|
-
url.searchParams.append("threshold", predictOptions.threshold.toString());
|
|
6
|
-
url.searchParams.append("min_frames", predictOptions.minFrames.toFixed());
|
|
7
|
-
url.searchParams.append("created_at", createdAt.toFixed());
|
|
8
|
-
const { created_at, is_bargein, probabilities } = await ofetch(
|
|
9
|
-
url.toString(),
|
|
10
|
-
{
|
|
11
|
-
retry: 1,
|
|
12
|
-
retryDelay: 100,
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/octet-stream",
|
|
15
|
-
Authorization: `Bearer ${options.token}`
|
|
16
|
-
},
|
|
17
|
-
signal: options.signal,
|
|
18
|
-
timeout: options.timeout,
|
|
19
|
-
method: "POST",
|
|
20
|
-
body: data
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
return {
|
|
24
|
-
createdAt: created_at,
|
|
25
|
-
isBargein: is_bargein,
|
|
26
|
-
probabilities: new Float32Array(probabilities),
|
|
27
|
-
predictionDuration: (performance.now() - createdAt) / 1e9
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
predictHTTP
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=http_transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/inference/interruption/http_transport.ts"],"sourcesContent":["import { ofetch } from 'ofetch';\n\nexport interface PostOptions {\n baseUrl: string;\n token: string;\n signal?: AbortSignal;\n timeout?: number;\n}\n\nexport interface PredictOptions {\n threshold: number;\n minFrames: number;\n}\n\nexport interface PredictEndpointResponse {\n created_at: number;\n is_bargein: boolean;\n probabilities: number[];\n}\n\nexport interface PredictResponse {\n createdAt: number;\n isBargein: boolean;\n probabilities: Float32Array;\n predictionDuration: number;\n}\n\nexport async function predictHTTP(\n data: Int16Array,\n predictOptions: PredictOptions,\n options: PostOptions,\n): Promise<PredictResponse> {\n const createdAt = performance.now();\n const url = new URL(`/bargein`, options.baseUrl);\n url.searchParams.append('threshold', predictOptions.threshold.toString());\n url.searchParams.append('min_frames', predictOptions.minFrames.toFixed());\n url.searchParams.append('created_at', createdAt.toFixed());\n\n const { created_at, is_bargein, probabilities } = await ofetch<PredictEndpointResponse>(\n url.toString(),\n {\n retry: 1,\n retryDelay: 100,\n headers: {\n 'Content-Type': 'application/octet-stream',\n Authorization: `Bearer ${options.token}`,\n },\n signal: options.signal,\n timeout: options.timeout,\n method: 'POST',\n body: data,\n },\n );\n\n return {\n createdAt: created_at,\n isBargein: is_bargein,\n probabilities: new Float32Array(probabilities),\n predictionDuration: (performance.now() - createdAt) / 1e9,\n };\n}\n"],"mappings":"AAAA,SAAS,cAAc;AA2BvB,eAAsB,YACpB,MACA,gBACA,SAC0B;AAC1B,QAAM,YAAY,YAAY,IAAI;AAClC,QAAM,MAAM,IAAI,IAAI,YAAY,QAAQ,OAAO;AAC/C,MAAI,aAAa,OAAO,aAAa,eAAe,UAAU,SAAS,CAAC;AACxE,MAAI,aAAa,OAAO,cAAc,eAAe,UAAU,QAAQ,CAAC;AACxE,MAAI,aAAa,OAAO,cAAc,UAAU,QAAQ,CAAC;AAEzD,QAAM,EAAE,YAAY,YAAY,cAAc,IAAI,MAAM;AAAA,IACtD,IAAI,SAAS;AAAA,IACb;AAAA,MACE,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe,UAAU,QAAQ,KAAK;AAAA,MACxC;AAAA,MACA,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,WAAW;AAAA,IACX,eAAe,IAAI,aAAa,aAAa;AAAA,IAC7C,qBAAqB,YAAY,IAAI,IAAI,aAAa;AAAA,EACxD;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/inference/interruption/index.ts"],"sourcesContent":["export * from './AdaptiveInterruptionDetector.js';\nexport * from './interruption.js';\nexport { InterruptionStreamSentinel } from './InterruptionStream.js';\nexport type { InterruptionSentinel } from './InterruptionStream.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAc,8CAAd;AACA,iCAAc,8BADd;AAEA,gCAA2C;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/inference/interruption/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/inference/interruption/index.ts"],"sourcesContent":["export * from './AdaptiveInterruptionDetector.js';\nexport * from './interruption.js';\nexport { InterruptionStreamSentinel } from './InterruptionStream.js';\nexport type { InterruptionSentinel } from './InterruptionStream.js';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,SAAS,kCAAkC;","names":[]}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var interruption_exports = {};
|
|
20
|
-
__export(interruption_exports, {
|
|
21
|
-
InterruptionCacheEntry: () => InterruptionCacheEntry,
|
|
22
|
-
InterruptionDetectionError: () => InterruptionDetectionError,
|
|
23
|
-
InterruptionEventType: () => InterruptionEventType
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(interruption_exports);
|
|
26
|
-
var import_utils = require("../utils.cjs");
|
|
27
|
-
var import_defaults = require("./defaults.cjs");
|
|
28
|
-
var InterruptionEventType = /* @__PURE__ */ ((InterruptionEventType2) => {
|
|
29
|
-
InterruptionEventType2["INTERRUPTION"] = "interruption";
|
|
30
|
-
InterruptionEventType2["OVERLAP_SPEECH_ENDED"] = "overlap_speech_ended";
|
|
31
|
-
return InterruptionEventType2;
|
|
32
|
-
})(InterruptionEventType || {});
|
|
33
|
-
class InterruptionDetectionError extends Error {
|
|
34
|
-
type = "InterruptionDetectionError";
|
|
35
|
-
timestamp;
|
|
36
|
-
label;
|
|
37
|
-
recoverable;
|
|
38
|
-
constructor(message, timestamp, label, recoverable) {
|
|
39
|
-
super(message);
|
|
40
|
-
this.name = "InterruptionDetectionError";
|
|
41
|
-
this.timestamp = timestamp;
|
|
42
|
-
this.label = label;
|
|
43
|
-
this.recoverable = recoverable;
|
|
44
|
-
}
|
|
45
|
-
toString() {
|
|
46
|
-
return `${this.name}: ${this.message} (label=${this.label}, timestamp=${this.timestamp}, recoverable=${this.recoverable})`;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function estimateProbability(probabilities, windowSize = import_defaults.MIN_INTERRUPTION_DURATION) {
|
|
50
|
-
const minWindow = Math.ceil(windowSize / 0.025);
|
|
51
|
-
if (probabilities.length < minWindow) {
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
return (0, import_utils.slidingWindowMinMax)(probabilities, windowSize);
|
|
55
|
-
}
|
|
56
|
-
class InterruptionCacheEntry {
|
|
57
|
-
createdAt;
|
|
58
|
-
totalDuration;
|
|
59
|
-
predictionDuration;
|
|
60
|
-
detectionDelay;
|
|
61
|
-
speechInput;
|
|
62
|
-
probabilities;
|
|
63
|
-
isInterruption;
|
|
64
|
-
probability;
|
|
65
|
-
constructor(params) {
|
|
66
|
-
this.createdAt = params.createdAt;
|
|
67
|
-
this.totalDuration = params.totalDuration ?? 0;
|
|
68
|
-
this.predictionDuration = params.predictionDuration ?? 0;
|
|
69
|
-
this.detectionDelay = params.detectionDelay ?? 0;
|
|
70
|
-
this.speechInput = params.speechInput;
|
|
71
|
-
this.probabilities = params.probabilities;
|
|
72
|
-
this.isInterruption = params.isInterruption;
|
|
73
|
-
this.probability = this.probabilities ? estimateProbability(this.probabilities) : 0;
|
|
74
|
-
}
|
|
75
|
-
static default() {
|
|
76
|
-
return new InterruptionCacheEntry({ createdAt: 0 });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
-
0 && (module.exports = {
|
|
81
|
-
InterruptionCacheEntry,
|
|
82
|
-
InterruptionDetectionError,
|
|
83
|
-
InterruptionEventType
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=interruption.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/inference/interruption/interruption.ts"],"sourcesContent":["import { slidingWindowMinMax } from '../utils.js';\nimport { MIN_INTERRUPTION_DURATION } from './defaults.js';\n\nexport enum InterruptionEventType {\n INTERRUPTION = 'interruption',\n OVERLAP_SPEECH_ENDED = 'overlap_speech_ended',\n}\nexport interface InterruptionEvent {\n type: InterruptionEventType;\n timestamp: number;\n isInterruption: boolean;\n totalDuration: number;\n predictionDuration: number;\n detectionDelay: number;\n overlapSpeechStartedAt?: number;\n speechInput?: Int16Array;\n probabilities?: Float32Array;\n probability: number;\n}\n\nexport class InterruptionDetectionError extends Error {\n readonly type = 'InterruptionDetectionError';\n\n readonly timestamp: number;\n readonly label: string;\n readonly recoverable: boolean;\n\n constructor(message: string, timestamp: number, label: string, recoverable: boolean) {\n super(message);\n this.name = 'InterruptionDetectionError';\n this.timestamp = timestamp;\n this.label = label;\n this.recoverable = recoverable;\n }\n\n toString(): string {\n return `${this.name}: ${this.message} (label=${this.label}, timestamp=${this.timestamp}, recoverable=${this.recoverable})`;\n }\n}\n\nfunction estimateProbability(\n probabilities: Float32Array,\n windowSize: number = MIN_INTERRUPTION_DURATION,\n): number {\n const minWindow = Math.ceil(windowSize / 0.025); // 25ms per frame\n if (probabilities.length < minWindow) {\n return 0;\n }\n\n return slidingWindowMinMax(probabilities, windowSize);\n}\n\n/**\n * Typed cache entry for interruption inference results.\n */\nexport class InterruptionCacheEntry {\n readonly createdAt: number;\n readonly totalDuration: number;\n readonly predictionDuration: number;\n readonly detectionDelay: number;\n readonly speechInput?: Int16Array;\n readonly probabilities?: Float32Array;\n readonly isInterruption?: boolean;\n readonly probability: number;\n\n constructor(params: {\n createdAt: number;\n speechInput?: Int16Array;\n totalDuration?: number;\n predictionDuration?: number;\n detectionDelay?: number;\n probabilities?: Float32Array;\n isInterruption?: boolean;\n }) {\n this.createdAt = params.createdAt;\n this.totalDuration = params.totalDuration ?? 0;\n this.predictionDuration = params.predictionDuration ?? 0;\n this.detectionDelay = params.detectionDelay ?? 0;\n this.speechInput = params.speechInput;\n this.probabilities = params.probabilities;\n this.isInterruption = params.isInterruption;\n this.probability = this.probabilities ? estimateProbability(this.probabilities) : 0;\n }\n\n static default(): InterruptionCacheEntry {\n return new InterruptionCacheEntry({ createdAt: 0 });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AACpC,sBAA0C;AAEnC,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,kBAAe;AACf,EAAAA,uBAAA,0BAAuB;AAFb,SAAAA;AAAA,GAAA;AAiBL,MAAM,mCAAmC,MAAM;AAAA,EAC3C,OAAO;AAAA,EAEP;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,WAAmB,OAAe,aAAsB;AACnF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,WAAmB;AACjB,WAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO,WAAW,KAAK,KAAK,eAAe,KAAK,SAAS,iBAAiB,KAAK,WAAW;AAAA,EACzH;AACF;AAEA,SAAS,oBACP,eACA,aAAqB,2CACb;AACR,QAAM,YAAY,KAAK,KAAK,aAAa,KAAK;AAC9C,MAAI,cAAc,SAAS,WAAW;AACpC,WAAO;AAAA,EACT;AAEA,aAAO,kCAAoB,eAAe,UAAU;AACtD;AAKO,MAAM,uBAAuB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAQT;AACD,SAAK,YAAY,OAAO;AACxB,SAAK,gBAAgB,OAAO,iBAAiB;AAC7C,SAAK,qBAAqB,OAAO,sBAAsB;AACvD,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,cAAc,OAAO;AAC1B,SAAK,gBAAgB,OAAO;AAC5B,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,KAAK,gBAAgB,oBAAoB,KAAK,aAAa,IAAI;AAAA,EACpF;AAAA,EAEA,OAAO,UAAkC;AACvC,WAAO,IAAI,uBAAuB,EAAE,WAAW,EAAE,CAAC;AAAA,EACpD;AACF;","names":["InterruptionEventType"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export declare enum InterruptionEventType {
|
|
2
|
-
INTERRUPTION = "interruption",
|
|
3
|
-
OVERLAP_SPEECH_ENDED = "overlap_speech_ended"
|
|
4
|
-
}
|
|
5
|
-
export interface InterruptionEvent {
|
|
6
|
-
type: InterruptionEventType;
|
|
7
|
-
timestamp: number;
|
|
8
|
-
isInterruption: boolean;
|
|
9
|
-
totalDuration: number;
|
|
10
|
-
predictionDuration: number;
|
|
11
|
-
detectionDelay: number;
|
|
12
|
-
overlapSpeechStartedAt?: number;
|
|
13
|
-
speechInput?: Int16Array;
|
|
14
|
-
probabilities?: Float32Array;
|
|
15
|
-
probability: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class InterruptionDetectionError extends Error {
|
|
18
|
-
readonly type = "InterruptionDetectionError";
|
|
19
|
-
readonly timestamp: number;
|
|
20
|
-
readonly label: string;
|
|
21
|
-
readonly recoverable: boolean;
|
|
22
|
-
constructor(message: string, timestamp: number, label: string, recoverable: boolean);
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Typed cache entry for interruption inference results.
|
|
27
|
-
*/
|
|
28
|
-
export declare class InterruptionCacheEntry {
|
|
29
|
-
readonly createdAt: number;
|
|
30
|
-
readonly totalDuration: number;
|
|
31
|
-
readonly predictionDuration: number;
|
|
32
|
-
readonly detectionDelay: number;
|
|
33
|
-
readonly speechInput?: Int16Array;
|
|
34
|
-
readonly probabilities?: Float32Array;
|
|
35
|
-
readonly isInterruption?: boolean;
|
|
36
|
-
readonly probability: number;
|
|
37
|
-
constructor(params: {
|
|
38
|
-
createdAt: number;
|
|
39
|
-
speechInput?: Int16Array;
|
|
40
|
-
totalDuration?: number;
|
|
41
|
-
predictionDuration?: number;
|
|
42
|
-
detectionDelay?: number;
|
|
43
|
-
probabilities?: Float32Array;
|
|
44
|
-
isInterruption?: boolean;
|
|
45
|
-
});
|
|
46
|
-
static default(): InterruptionCacheEntry;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=interruption.d.ts.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export declare enum InterruptionEventType {
|
|
2
|
-
INTERRUPTION = "interruption",
|
|
3
|
-
OVERLAP_SPEECH_ENDED = "overlap_speech_ended"
|
|
4
|
-
}
|
|
5
|
-
export interface InterruptionEvent {
|
|
6
|
-
type: InterruptionEventType;
|
|
7
|
-
timestamp: number;
|
|
8
|
-
isInterruption: boolean;
|
|
9
|
-
totalDuration: number;
|
|
10
|
-
predictionDuration: number;
|
|
11
|
-
detectionDelay: number;
|
|
12
|
-
overlapSpeechStartedAt?: number;
|
|
13
|
-
speechInput?: Int16Array;
|
|
14
|
-
probabilities?: Float32Array;
|
|
15
|
-
probability: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class InterruptionDetectionError extends Error {
|
|
18
|
-
readonly type = "InterruptionDetectionError";
|
|
19
|
-
readonly timestamp: number;
|
|
20
|
-
readonly label: string;
|
|
21
|
-
readonly recoverable: boolean;
|
|
22
|
-
constructor(message: string, timestamp: number, label: string, recoverable: boolean);
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Typed cache entry for interruption inference results.
|
|
27
|
-
*/
|
|
28
|
-
export declare class InterruptionCacheEntry {
|
|
29
|
-
readonly createdAt: number;
|
|
30
|
-
readonly totalDuration: number;
|
|
31
|
-
readonly predictionDuration: number;
|
|
32
|
-
readonly detectionDelay: number;
|
|
33
|
-
readonly speechInput?: Int16Array;
|
|
34
|
-
readonly probabilities?: Float32Array;
|
|
35
|
-
readonly isInterruption?: boolean;
|
|
36
|
-
readonly probability: number;
|
|
37
|
-
constructor(params: {
|
|
38
|
-
createdAt: number;
|
|
39
|
-
speechInput?: Int16Array;
|
|
40
|
-
totalDuration?: number;
|
|
41
|
-
predictionDuration?: number;
|
|
42
|
-
detectionDelay?: number;
|
|
43
|
-
probabilities?: Float32Array;
|
|
44
|
-
isInterruption?: boolean;
|
|
45
|
-
});
|
|
46
|
-
static default(): InterruptionCacheEntry;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=interruption.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interruption.d.ts","sourceRoot":"","sources":["../../../src/inference/interruption/interruption.ts"],"names":[],"mappings":"AAGA,oBAAY,qBAAqB;IAC/B,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;CAC9C;AACD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,gCAAgC;IAE7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO;IAQnF,QAAQ,IAAI,MAAM;CAGnB;AAcD;;GAEG;AACH,qBAAa,sBAAsB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,UAAU,CAAC;QACzB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,YAAY,CAAC;QAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B;IAWD,MAAM,CAAC,OAAO,IAAI,sBAAsB;CAGzC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { slidingWindowMinMax } from "../utils.js";
|
|
2
|
-
import { MIN_INTERRUPTION_DURATION } from "./defaults.js";
|
|
3
|
-
var InterruptionEventType = /* @__PURE__ */ ((InterruptionEventType2) => {
|
|
4
|
-
InterruptionEventType2["INTERRUPTION"] = "interruption";
|
|
5
|
-
InterruptionEventType2["OVERLAP_SPEECH_ENDED"] = "overlap_speech_ended";
|
|
6
|
-
return InterruptionEventType2;
|
|
7
|
-
})(InterruptionEventType || {});
|
|
8
|
-
class InterruptionDetectionError extends Error {
|
|
9
|
-
type = "InterruptionDetectionError";
|
|
10
|
-
timestamp;
|
|
11
|
-
label;
|
|
12
|
-
recoverable;
|
|
13
|
-
constructor(message, timestamp, label, recoverable) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = "InterruptionDetectionError";
|
|
16
|
-
this.timestamp = timestamp;
|
|
17
|
-
this.label = label;
|
|
18
|
-
this.recoverable = recoverable;
|
|
19
|
-
}
|
|
20
|
-
toString() {
|
|
21
|
-
return `${this.name}: ${this.message} (label=${this.label}, timestamp=${this.timestamp}, recoverable=${this.recoverable})`;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function estimateProbability(probabilities, windowSize = MIN_INTERRUPTION_DURATION) {
|
|
25
|
-
const minWindow = Math.ceil(windowSize / 0.025);
|
|
26
|
-
if (probabilities.length < minWindow) {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
return slidingWindowMinMax(probabilities, windowSize);
|
|
30
|
-
}
|
|
31
|
-
class InterruptionCacheEntry {
|
|
32
|
-
createdAt;
|
|
33
|
-
totalDuration;
|
|
34
|
-
predictionDuration;
|
|
35
|
-
detectionDelay;
|
|
36
|
-
speechInput;
|
|
37
|
-
probabilities;
|
|
38
|
-
isInterruption;
|
|
39
|
-
probability;
|
|
40
|
-
constructor(params) {
|
|
41
|
-
this.createdAt = params.createdAt;
|
|
42
|
-
this.totalDuration = params.totalDuration ?? 0;
|
|
43
|
-
this.predictionDuration = params.predictionDuration ?? 0;
|
|
44
|
-
this.detectionDelay = params.detectionDelay ?? 0;
|
|
45
|
-
this.speechInput = params.speechInput;
|
|
46
|
-
this.probabilities = params.probabilities;
|
|
47
|
-
this.isInterruption = params.isInterruption;
|
|
48
|
-
this.probability = this.probabilities ? estimateProbability(this.probabilities) : 0;
|
|
49
|
-
}
|
|
50
|
-
static default() {
|
|
51
|
-
return new InterruptionCacheEntry({ createdAt: 0 });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
InterruptionCacheEntry,
|
|
56
|
-
InterruptionDetectionError,
|
|
57
|
-
InterruptionEventType
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=interruption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/inference/interruption/interruption.ts"],"sourcesContent":["import { slidingWindowMinMax } from '../utils.js';\nimport { MIN_INTERRUPTION_DURATION } from './defaults.js';\n\nexport enum InterruptionEventType {\n INTERRUPTION = 'interruption',\n OVERLAP_SPEECH_ENDED = 'overlap_speech_ended',\n}\nexport interface InterruptionEvent {\n type: InterruptionEventType;\n timestamp: number;\n isInterruption: boolean;\n totalDuration: number;\n predictionDuration: number;\n detectionDelay: number;\n overlapSpeechStartedAt?: number;\n speechInput?: Int16Array;\n probabilities?: Float32Array;\n probability: number;\n}\n\nexport class InterruptionDetectionError extends Error {\n readonly type = 'InterruptionDetectionError';\n\n readonly timestamp: number;\n readonly label: string;\n readonly recoverable: boolean;\n\n constructor(message: string, timestamp: number, label: string, recoverable: boolean) {\n super(message);\n this.name = 'InterruptionDetectionError';\n this.timestamp = timestamp;\n this.label = label;\n this.recoverable = recoverable;\n }\n\n toString(): string {\n return `${this.name}: ${this.message} (label=${this.label}, timestamp=${this.timestamp}, recoverable=${this.recoverable})`;\n }\n}\n\nfunction estimateProbability(\n probabilities: Float32Array,\n windowSize: number = MIN_INTERRUPTION_DURATION,\n): number {\n const minWindow = Math.ceil(windowSize / 0.025); // 25ms per frame\n if (probabilities.length < minWindow) {\n return 0;\n }\n\n return slidingWindowMinMax(probabilities, windowSize);\n}\n\n/**\n * Typed cache entry for interruption inference results.\n */\nexport class InterruptionCacheEntry {\n readonly createdAt: number;\n readonly totalDuration: number;\n readonly predictionDuration: number;\n readonly detectionDelay: number;\n readonly speechInput?: Int16Array;\n readonly probabilities?: Float32Array;\n readonly isInterruption?: boolean;\n readonly probability: number;\n\n constructor(params: {\n createdAt: number;\n speechInput?: Int16Array;\n totalDuration?: number;\n predictionDuration?: number;\n detectionDelay?: number;\n probabilities?: Float32Array;\n isInterruption?: boolean;\n }) {\n this.createdAt = params.createdAt;\n this.totalDuration = params.totalDuration ?? 0;\n this.predictionDuration = params.predictionDuration ?? 0;\n this.detectionDelay = params.detectionDelay ?? 0;\n this.speechInput = params.speechInput;\n this.probabilities = params.probabilities;\n this.isInterruption = params.isInterruption;\n this.probability = this.probabilities ? estimateProbability(this.probabilities) : 0;\n }\n\n static default(): InterruptionCacheEntry {\n return new InterruptionCacheEntry({ createdAt: 0 });\n }\n}\n"],"mappings":"AAAA,SAAS,2BAA2B;AACpC,SAAS,iCAAiC;AAEnC,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,kBAAe;AACf,EAAAA,uBAAA,0BAAuB;AAFb,SAAAA;AAAA,GAAA;AAiBL,MAAM,mCAAmC,MAAM;AAAA,EAC3C,OAAO;AAAA,EAEP;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,WAAmB,OAAe,aAAsB;AACnF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,WAAmB;AACjB,WAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO,WAAW,KAAK,KAAK,eAAe,KAAK,SAAS,iBAAiB,KAAK,WAAW;AAAA,EACzH;AACF;AAEA,SAAS,oBACP,eACA,aAAqB,2BACb;AACR,QAAM,YAAY,KAAK,KAAK,aAAa,KAAK;AAC9C,MAAI,cAAc,SAAS,WAAW;AACpC,WAAO;AAAA,EACT;AAEA,SAAO,oBAAoB,eAAe,UAAU;AACtD;AAKO,MAAM,uBAAuB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAQT;AACD,SAAK,YAAY,OAAO;AACxB,SAAK,gBAAgB,OAAO,iBAAiB;AAC7C,SAAK,qBAAqB,OAAO,sBAAsB;AACvD,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,cAAc,OAAO;AAC1B,SAAK,gBAAgB,OAAO;AAC5B,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,KAAK,gBAAgB,oBAAoB,KAAK,aAAa,IAAI;AAAA,EACpF;AAAA,EAEA,OAAO,UAAkC;AACvC,WAAO,IAAI,uBAAuB,EAAE,WAAW,EAAE,CAAC;AAAA,EACpD;AACF;","names":["InterruptionEventType"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_vitest = require("vitest");
|
|
3
|
-
var import_utils = require("./utils.cjs");
|
|
4
|
-
(0, import_vitest.describe)("slidingWindowMinMax", () => {
|
|
5
|
-
(0, import_vitest.it)("returns -Infinity when array is shorter than window size", () => {
|
|
6
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([0.5, 0.6], 3)).toBe(-Infinity);
|
|
7
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([], 1)).toBe(-Infinity);
|
|
8
|
-
});
|
|
9
|
-
(0, import_vitest.it)("returns the max value when window size is 1", () => {
|
|
10
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([0.1, 0.5, 0.3, 0.8, 0.2], 1)).toBe(0.8);
|
|
11
|
-
});
|
|
12
|
-
(0, import_vitest.it)("finds the best sustained probability across windows", () => {
|
|
13
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([0.2, 0.8, 0.7, 0.3, 0.9], 3)).toBe(0.3);
|
|
14
|
-
});
|
|
15
|
-
(0, import_vitest.it)("returns the single element when array length equals window size", () => {
|
|
16
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([0.5, 0.9, 0.7], 3)).toBe(0.5);
|
|
17
|
-
(0, import_vitest.expect)((0, import_utils.slidingWindowMinMax)([0.8], 1)).toBe(0.8);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=utils.test.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/inference/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { slidingWindowMinMax } from './utils.js';\n\ndescribe('slidingWindowMinMax', () => {\n it('returns -Infinity when array is shorter than window size', () => {\n expect(slidingWindowMinMax([0.5, 0.6], 3)).toBe(-Infinity);\n expect(slidingWindowMinMax([], 1)).toBe(-Infinity);\n });\n\n it('returns the max value when window size is 1', () => {\n // With window size 1, min of each window is the element itself,\n // so max of mins is just the max of the array\n expect(slidingWindowMinMax([0.1, 0.5, 0.3, 0.8, 0.2], 1)).toBe(0.8);\n });\n\n it('finds the best sustained probability across windows', () => {\n // Windows of size 3: [0.2, 0.8, 0.7], [0.8, 0.7, 0.3], [0.7, 0.3, 0.9]\n // Mins: 0.2, 0.3, 0.3\n // Max of mins: 0.3\n expect(slidingWindowMinMax([0.2, 0.8, 0.7, 0.3, 0.9], 3)).toBe(0.3);\n });\n\n it('returns the single element when array length equals window size', () => {\n // Only one window covering the entire array, return min of that window\n expect(slidingWindowMinMax([0.5, 0.9, 0.7], 3)).toBe(0.5);\n expect(slidingWindowMinMax([0.8], 1)).toBe(0.8);\n });\n});\n"],"mappings":";AAGA,oBAAqC;AACrC,mBAAoC;AAAA,IAEpC,wBAAS,uBAAuB,MAAM;AACpC,wBAAG,4DAA4D,MAAM;AACnE,kCAAO,kCAAoB,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AACzD,kCAAO,kCAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AAAA,EACnD,CAAC;AAED,wBAAG,+CAA+C,MAAM;AAGtD,kCAAO,kCAAoB,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EACpE,CAAC;AAED,wBAAG,uDAAuD,MAAM;AAI9D,kCAAO,kCAAoB,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EACpE,CAAC;AAED,wBAAG,mEAAmE,MAAM;AAE1E,kCAAO,kCAAoB,CAAC,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AACxD,kCAAO,kCAAoB,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EAChD,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { slidingWindowMinMax } from "./utils.js";
|
|
3
|
-
describe("slidingWindowMinMax", () => {
|
|
4
|
-
it("returns -Infinity when array is shorter than window size", () => {
|
|
5
|
-
expect(slidingWindowMinMax([0.5, 0.6], 3)).toBe(-Infinity);
|
|
6
|
-
expect(slidingWindowMinMax([], 1)).toBe(-Infinity);
|
|
7
|
-
});
|
|
8
|
-
it("returns the max value when window size is 1", () => {
|
|
9
|
-
expect(slidingWindowMinMax([0.1, 0.5, 0.3, 0.8, 0.2], 1)).toBe(0.8);
|
|
10
|
-
});
|
|
11
|
-
it("finds the best sustained probability across windows", () => {
|
|
12
|
-
expect(slidingWindowMinMax([0.2, 0.8, 0.7, 0.3, 0.9], 3)).toBe(0.3);
|
|
13
|
-
});
|
|
14
|
-
it("returns the single element when array length equals window size", () => {
|
|
15
|
-
expect(slidingWindowMinMax([0.5, 0.9, 0.7], 3)).toBe(0.5);
|
|
16
|
-
expect(slidingWindowMinMax([0.8], 1)).toBe(0.8);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=utils.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/inference/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { slidingWindowMinMax } from './utils.js';\n\ndescribe('slidingWindowMinMax', () => {\n it('returns -Infinity when array is shorter than window size', () => {\n expect(slidingWindowMinMax([0.5, 0.6], 3)).toBe(-Infinity);\n expect(slidingWindowMinMax([], 1)).toBe(-Infinity);\n });\n\n it('returns the max value when window size is 1', () => {\n // With window size 1, min of each window is the element itself,\n // so max of mins is just the max of the array\n expect(slidingWindowMinMax([0.1, 0.5, 0.3, 0.8, 0.2], 1)).toBe(0.8);\n });\n\n it('finds the best sustained probability across windows', () => {\n // Windows of size 3: [0.2, 0.8, 0.7], [0.8, 0.7, 0.3], [0.7, 0.3, 0.9]\n // Mins: 0.2, 0.3, 0.3\n // Max of mins: 0.3\n expect(slidingWindowMinMax([0.2, 0.8, 0.7, 0.3, 0.9], 3)).toBe(0.3);\n });\n\n it('returns the single element when array length equals window size', () => {\n // Only one window covering the entire array, return min of that window\n expect(slidingWindowMinMax([0.5, 0.9, 0.7], 3)).toBe(0.5);\n expect(slidingWindowMinMax([0.8], 1)).toBe(0.8);\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,2BAA2B;AAEpC,SAAS,uBAAuB,MAAM;AACpC,KAAG,4DAA4D,MAAM;AACnE,WAAO,oBAAoB,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AACzD,WAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AAAA,EACnD,CAAC;AAED,KAAG,+CAA+C,MAAM;AAGtD,WAAO,oBAAoB,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EACpE,CAAC;AAED,KAAG,uDAAuD,MAAM;AAI9D,WAAO,oBAAoB,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EACpE,CAAC;AAED,KAAG,mEAAmE,MAAM;AAE1E,WAAO,oBAAoB,CAAC,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AACxD,WAAO,oBAAoB,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG;AAAA,EAChD,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var ws_transport_exports = {};
|
|
30
|
-
__export(ws_transport_exports, {
|
|
31
|
-
webSocketStream: () => webSocketStream
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(ws_transport_exports);
|
|
34
|
-
var import_node_stream = require("node:stream");
|
|
35
|
-
var import_ws = __toESM(require("ws"), 1);
|
|
36
|
-
function webSocketStream(wsUrl) {
|
|
37
|
-
const ws = new import_ws.default(wsUrl);
|
|
38
|
-
const duplex = (0, import_ws.createWebSocketStream)(ws);
|
|
39
|
-
duplex.on("error", console.error);
|
|
40
|
-
duplex.on("end", () => {
|
|
41
|
-
duplex.end();
|
|
42
|
-
});
|
|
43
|
-
const writable = import_node_stream.Writable.toWeb(duplex);
|
|
44
|
-
const readable = import_node_stream.Readable.toWeb(duplex);
|
|
45
|
-
return { readable, writable, close: ws.close };
|
|
46
|
-
}
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
webSocketStream
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=ws_transport.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/ws_transport.ts"],"sourcesContent":["import { Readable, Writable } from 'node:stream';\nimport WebSocket, { createWebSocketStream } from 'ws';\n\nexport function webSocketStream(wsUrl: string) {\n const ws = new WebSocket(wsUrl);\n const duplex = createWebSocketStream(ws);\n duplex.on('error', console.error);\n\n // End the write side when the read side ends to properly close the stream.\n // This is needed because Readable.toWeb() waits for both sides of the duplex\n // to close before signaling done on the ReadableStream.\n duplex.on('end', () => {\n duplex.end();\n });\n\n // Convert the writable side\n const writable = Writable.toWeb(duplex);\n // Convert the readable side\n const readable = Readable.toWeb(duplex);\n\n return { readable, writable, close: ws.close };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmC;AACnC,gBAAiD;AAE1C,SAAS,gBAAgB,OAAe;AAC7C,QAAM,KAAK,IAAI,UAAAA,QAAU,KAAK;AAC9B,QAAM,aAAS,iCAAsB,EAAE;AACvC,SAAO,GAAG,SAAS,QAAQ,KAAK;AAKhC,SAAO,GAAG,OAAO,MAAM;AACrB,WAAO,IAAI;AAAA,EACb,CAAC;AAGD,QAAM,WAAW,4BAAS,MAAM,MAAM;AAEtC,QAAM,WAAW,4BAAS,MAAM,MAAM;AAEtC,SAAO,EAAE,UAAU,UAAU,OAAO,GAAG,MAAM;AAC/C;","names":["WebSocket"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
-
export declare function webSocketStream(wsUrl: string): {
|
|
5
|
-
readable: import("stream/web").ReadableStream<any>;
|
|
6
|
-
writable: import("stream/web").WritableStream<any>;
|
|
7
|
-
close: (code?: number | undefined, data?: string | Buffer | undefined) => void;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=ws_transport.d.ts.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
-
export declare function webSocketStream(wsUrl: string): {
|
|
5
|
-
readable: import("stream/web").ReadableStream<any>;
|
|
6
|
-
writable: import("stream/web").WritableStream<any>;
|
|
7
|
-
close: (code?: number | undefined, data?: string | Buffer | undefined) => void;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=ws_transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws_transport.d.ts","sourceRoot":"","sources":["../../src/utils/ws_transport.ts"],"names":[],"mappings":";;;AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM;;;;EAkB5C"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Readable, Writable } from "node:stream";
|
|
2
|
-
import WebSocket, { createWebSocketStream } from "ws";
|
|
3
|
-
function webSocketStream(wsUrl) {
|
|
4
|
-
const ws = new WebSocket(wsUrl);
|
|
5
|
-
const duplex = createWebSocketStream(ws);
|
|
6
|
-
duplex.on("error", console.error);
|
|
7
|
-
duplex.on("end", () => {
|
|
8
|
-
duplex.end();
|
|
9
|
-
});
|
|
10
|
-
const writable = Writable.toWeb(duplex);
|
|
11
|
-
const readable = Readable.toWeb(duplex);
|
|
12
|
-
return { readable, writable, close: ws.close };
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
webSocketStream
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=ws_transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/ws_transport.ts"],"sourcesContent":["import { Readable, Writable } from 'node:stream';\nimport WebSocket, { createWebSocketStream } from 'ws';\n\nexport function webSocketStream(wsUrl: string) {\n const ws = new WebSocket(wsUrl);\n const duplex = createWebSocketStream(ws);\n duplex.on('error', console.error);\n\n // End the write side when the read side ends to properly close the stream.\n // This is needed because Readable.toWeb() waits for both sides of the duplex\n // to close before signaling done on the ReadableStream.\n duplex.on('end', () => {\n duplex.end();\n });\n\n // Convert the writable side\n const writable = Writable.toWeb(duplex);\n // Convert the readable side\n const readable = Readable.toWeb(duplex);\n\n return { readable, writable, close: ws.close };\n}\n"],"mappings":"AAAA,SAAS,UAAU,gBAAgB;AACnC,OAAO,aAAa,6BAA6B;AAE1C,SAAS,gBAAgB,OAAe;AAC7C,QAAM,KAAK,IAAI,UAAU,KAAK;AAC9B,QAAM,SAAS,sBAAsB,EAAE;AACvC,SAAO,GAAG,SAAS,QAAQ,KAAK;AAKhC,SAAO,GAAG,OAAO,MAAM;AACrB,WAAO,IAAI;AAAA,EACb,CAAC;AAGD,QAAM,WAAW,SAAS,MAAM,MAAM;AAEtC,QAAM,WAAW,SAAS,MAAM,MAAM;AAEtC,SAAO,EAAE,UAAU,UAAU,OAAO,GAAG,MAAM;AAC/C;","names":[]}
|