@graphen.ai/aiia-sdk 1.0.20 → 1.1.0-beta.17
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/VERSION-8NGV8OB9.d.ts +485 -0
- package/dist/aiia-worklet.js +1 -1
- package/dist/browser/index.d.ts +51 -150
- package/dist/browser/index.js +13 -10
- package/dist/browser/index.mjs +13 -10
- package/dist/nodejs/index.d.ts +389 -5
- package/dist/nodejs/index.js +20 -14
- package/dist/nodejs/index.mjs +20 -14
- package/package.json +21 -20
- package/dist/type-RVXBPx7G.d.ts +0 -199
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { BoundingBox, Landmark } from '@mediapipe/tasks-vision';
|
|
2
|
+
import { Server } from 'http';
|
|
3
|
+
import { Server as Server$1 } from 'https';
|
|
4
|
+
import { Http2SecureServer, Http2Server } from 'http2';
|
|
5
|
+
import * as node_http2 from 'node:http2';
|
|
6
|
+
import * as node_https from 'node:https';
|
|
7
|
+
import * as node_http from 'node:http';
|
|
8
|
+
|
|
9
|
+
interface Result extends BoundingBox {
|
|
10
|
+
area: number;
|
|
11
|
+
score: number;
|
|
12
|
+
clientWidth: number;
|
|
13
|
+
clientHeight: number;
|
|
14
|
+
}
|
|
15
|
+
type AnalysisResult = Result | null;
|
|
16
|
+
type Vec2 = {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface AiiaProjectItem {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}
|
|
25
|
+
type LoggerLevel = "info" | "error" | "warn" | "debug" | "fatal" | "code";
|
|
26
|
+
type Webserver = Server<any, any> | Server$1<any, any> | Http2SecureServer<any, any, any, any> | Http2Server<any, any, any, any>;
|
|
27
|
+
interface CommonOptions {
|
|
28
|
+
/**
|
|
29
|
+
* [zh]
|
|
30
|
+
* 顯示訊息(一般、錯誤、警告),預設 true
|
|
31
|
+
*
|
|
32
|
+
* [en]
|
|
33
|
+
* Switch message(info, error, warn) display, default: true
|
|
34
|
+
*/
|
|
35
|
+
debug?: boolean | "all" | "none" | LoggerLevel[];
|
|
36
|
+
}
|
|
37
|
+
interface NodeInitOptions extends CommonOptions {
|
|
38
|
+
/**
|
|
39
|
+
* [zh]
|
|
40
|
+
* 簡易的機台資訊備註,於管理系統查看
|
|
41
|
+
*
|
|
42
|
+
* [en]
|
|
43
|
+
* Simple machine/device information notes, viewable in the management system.
|
|
44
|
+
*/
|
|
45
|
+
note?: string;
|
|
46
|
+
/**
|
|
47
|
+
* [zh]
|
|
48
|
+
* 設定機台名稱,於管理系統查看
|
|
49
|
+
*
|
|
50
|
+
* [en]
|
|
51
|
+
* Setting machine/device name, viewable in the management system.
|
|
52
|
+
*/
|
|
53
|
+
device_name?: string;
|
|
54
|
+
/**
|
|
55
|
+
* [zh]
|
|
56
|
+
* 請從 Aiia platform 取得授權
|
|
57
|
+
*
|
|
58
|
+
* [en]
|
|
59
|
+
* Please go to Aiia platform and get group id
|
|
60
|
+
*/
|
|
61
|
+
group_id?: string;
|
|
62
|
+
/**
|
|
63
|
+
* [zh]
|
|
64
|
+
* 擴充 "socket.io" 到網頁伺服器
|
|
65
|
+
*
|
|
66
|
+
* [en]
|
|
67
|
+
* Extending "socket.io" to your web server
|
|
68
|
+
*/
|
|
69
|
+
webserver?: Webserver;
|
|
70
|
+
/**
|
|
71
|
+
* [zh]
|
|
72
|
+
* 伺服器 port
|
|
73
|
+
*
|
|
74
|
+
* [en]
|
|
75
|
+
* Server port
|
|
76
|
+
*
|
|
77
|
+
* process.env.PORT > port > 3000(default port)
|
|
78
|
+
*/
|
|
79
|
+
port?: number;
|
|
80
|
+
/**
|
|
81
|
+
* [zh]
|
|
82
|
+
* 指定的環境,預設值: production
|
|
83
|
+
*
|
|
84
|
+
* [en]
|
|
85
|
+
* Specific Env, default: production
|
|
86
|
+
*/
|
|
87
|
+
env?: "developement" | "production";
|
|
88
|
+
/**
|
|
89
|
+
* [zh]
|
|
90
|
+
* 指定雲端位置(會覆蓋 `env` 設定)
|
|
91
|
+
*
|
|
92
|
+
* [en]
|
|
93
|
+
* Specify cloud location(override `env` settings)
|
|
94
|
+
*/
|
|
95
|
+
cloudEndPoint?: string;
|
|
96
|
+
/**
|
|
97
|
+
* [zh]
|
|
98
|
+
* 啟動眼球追蹤
|
|
99
|
+
*
|
|
100
|
+
* [en]
|
|
101
|
+
* Start eye tracking
|
|
102
|
+
*/
|
|
103
|
+
eyeTrackEnable?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* [zh]
|
|
106
|
+
* 眼球追蹤補正,請根據 Camera 裝置的物理位置添加補正值。
|
|
107
|
+
*
|
|
108
|
+
* [en]
|
|
109
|
+
* Eye tracking correction, please add correction value according to the physical position of the camera device.
|
|
110
|
+
*/
|
|
111
|
+
correction?: {
|
|
112
|
+
x_axis_px?: number;
|
|
113
|
+
y_axis_px?: number;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* [zh]
|
|
117
|
+
* 是否連接 Avatar 服務? (預設 true)
|
|
118
|
+
*
|
|
119
|
+
* [en]
|
|
120
|
+
* Connect to Avatar service? (Default: true)
|
|
121
|
+
*/
|
|
122
|
+
avatartService?: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface BrowserInitOptions extends CommonOptions {
|
|
125
|
+
/**
|
|
126
|
+
* [zh]
|
|
127
|
+
* 專案名稱 或是 專案編號(ID)
|
|
128
|
+
*
|
|
129
|
+
* [en]
|
|
130
|
+
* Project name/ID
|
|
131
|
+
*/
|
|
132
|
+
project?: string | Partial<AiiaProjectItem>;
|
|
133
|
+
/**
|
|
134
|
+
* [zh]
|
|
135
|
+
* 瀏覽器連線指定 Websocket url
|
|
136
|
+
*
|
|
137
|
+
* [en]
|
|
138
|
+
* specific websocket url for Browser use
|
|
139
|
+
*/
|
|
140
|
+
ws_url?: string;
|
|
141
|
+
/**
|
|
142
|
+
* [zh]
|
|
143
|
+
* 分析音訊的模組網址
|
|
144
|
+
*
|
|
145
|
+
* [en]
|
|
146
|
+
* Module URL for analyzing audio
|
|
147
|
+
*/
|
|
148
|
+
worklet_url?: string;
|
|
149
|
+
/**
|
|
150
|
+
* [zh]
|
|
151
|
+
* 授權的媒體裝置,請包含麥克風及鏡頭/攝影機權限
|
|
152
|
+
*
|
|
153
|
+
* 若不打算使用,請傳入`null`,將會避免自動請求權限。
|
|
154
|
+
*
|
|
155
|
+
* [en]
|
|
156
|
+
* Authorized media devices, please include microphone and lens/camera permissions.
|
|
157
|
+
*
|
|
158
|
+
* If you do not intend to use this, please pass `null` to avoid automatically requesting permissions.
|
|
159
|
+
*
|
|
160
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaStream
|
|
161
|
+
*/
|
|
162
|
+
mediaStream?: MediaStream | null;
|
|
163
|
+
/**
|
|
164
|
+
* [zh]
|
|
165
|
+
* 檢測聲音的區塊大小(秒),預設 0.3 秒
|
|
166
|
+
*
|
|
167
|
+
* [en]
|
|
168
|
+
* Detecting the chunk size of the sound(unit is second), default 0.3 second.
|
|
169
|
+
*/
|
|
170
|
+
chunkTimeInSeconds?: number;
|
|
171
|
+
/**
|
|
172
|
+
* [zh]
|
|
173
|
+
* 指定音訊輸出的採樣率(提供給LLM分析)。不推薦更動
|
|
174
|
+
*
|
|
175
|
+
* [en]
|
|
176
|
+
* Specify the sampling rate of audio output (provided for LLM analysis). Changing is not recommended.
|
|
177
|
+
*/
|
|
178
|
+
llmSampleRate?: number;
|
|
179
|
+
/**
|
|
180
|
+
* [zh]
|
|
181
|
+
* 攝影機辨識設定
|
|
182
|
+
*
|
|
183
|
+
* @property perSecond: 每秒檢測幾次, 預設: 每秒 3 次
|
|
184
|
+
*
|
|
185
|
+
* @property confidence: 人臉辨識分數(0 ~ 100), 預設: 80
|
|
186
|
+
*
|
|
187
|
+
* [en]
|
|
188
|
+
* Camera Identification Settings
|
|
189
|
+
*
|
|
190
|
+
* @property perSecond: Detection times per second, default: 3 times per second
|
|
191
|
+
*
|
|
192
|
+
* @property confidence: Face recognition score(0 ~ 100), default: 80
|
|
193
|
+
*/
|
|
194
|
+
cameraDetection?: {
|
|
195
|
+
perSecond?: number;
|
|
196
|
+
confidence?: number;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* [zh]
|
|
200
|
+
* 清除字幕,可指定時間(毫秒),預設 5000 毫秒後清除
|
|
201
|
+
*
|
|
202
|
+
* [en]
|
|
203
|
+
* Clear subtitles, you can specify the time (milliseconds), the default is to clear after 5000 milliseconds.
|
|
204
|
+
*/
|
|
205
|
+
autoClearUserSubtitle?: number;
|
|
206
|
+
/**
|
|
207
|
+
* [zh]
|
|
208
|
+
* 清除字幕,可指定時間(毫秒),預設 音訊結束時 清除
|
|
209
|
+
*
|
|
210
|
+
* [en]
|
|
211
|
+
* Clear subtitles, you can specify the time (milliseconds), the default Clear when audio ends.
|
|
212
|
+
*/
|
|
213
|
+
autoClearAiiaSubtitle?: number;
|
|
214
|
+
}
|
|
215
|
+
type InitOptions = NodeInitOptions & BrowserInitOptions;
|
|
216
|
+
|
|
217
|
+
interface TTS {
|
|
218
|
+
signal: "tts";
|
|
219
|
+
content: {
|
|
220
|
+
status: "start" | "next" | "end";
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
interface MIC {
|
|
224
|
+
signal: "mic";
|
|
225
|
+
content: {
|
|
226
|
+
status: "on" | "off" | "wait" | "waitting";
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
interface ASR {
|
|
230
|
+
signal: "asr";
|
|
231
|
+
content: {
|
|
232
|
+
function_type: undefined;
|
|
233
|
+
status: "voice";
|
|
234
|
+
} | {
|
|
235
|
+
function_type: "voice_detection";
|
|
236
|
+
} | {
|
|
237
|
+
function_type: "ASR";
|
|
238
|
+
function_result: {
|
|
239
|
+
lang: string;
|
|
240
|
+
result: string;
|
|
241
|
+
filename: string | null;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** @deprecated */
|
|
246
|
+
interface OLD_ASR {
|
|
247
|
+
signal: "transcribe";
|
|
248
|
+
content: {
|
|
249
|
+
status: string;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
interface RATINGS {
|
|
253
|
+
signal: "rating";
|
|
254
|
+
content: {
|
|
255
|
+
status: string;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
interface AGENT_function_result_control {
|
|
259
|
+
panel: string | null;
|
|
260
|
+
chat: boolean;
|
|
261
|
+
auto_continue: boolean;
|
|
262
|
+
}
|
|
263
|
+
interface AGENT_function_result_properties {
|
|
264
|
+
panel: string | null;
|
|
265
|
+
chat?: number;
|
|
266
|
+
auto_continue?: number;
|
|
267
|
+
title?: string;
|
|
268
|
+
images: string[];
|
|
269
|
+
}
|
|
270
|
+
interface AGENT_function_result {
|
|
271
|
+
response: string;
|
|
272
|
+
resp_type: string;
|
|
273
|
+
lang: number;
|
|
274
|
+
string: string;
|
|
275
|
+
control: AGENT_function_result_control;
|
|
276
|
+
properties: AGENT_function_result_properties;
|
|
277
|
+
}
|
|
278
|
+
interface AGENT {
|
|
279
|
+
signal: "agent";
|
|
280
|
+
content: {
|
|
281
|
+
function_type: "response";
|
|
282
|
+
function_result: AGENT_function_result;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
interface OLD_AGENT_content_1 {
|
|
286
|
+
id: string;
|
|
287
|
+
type: undefined;
|
|
288
|
+
scenario: "tutorial" | undefined;
|
|
289
|
+
state: string;
|
|
290
|
+
auto_continue: number;
|
|
291
|
+
chat: number;
|
|
292
|
+
res: string;
|
|
293
|
+
fe_pre_msg: null;
|
|
294
|
+
photo?: string;
|
|
295
|
+
}
|
|
296
|
+
interface OLD_AGENT_content_2 {
|
|
297
|
+
type: "nlu" | "scenario";
|
|
298
|
+
scenario: string;
|
|
299
|
+
state: string;
|
|
300
|
+
res: string[];
|
|
301
|
+
photo?: string;
|
|
302
|
+
}
|
|
303
|
+
/** @deprecated */
|
|
304
|
+
interface OLD_AGENT {
|
|
305
|
+
signal: "response";
|
|
306
|
+
content: OLD_AGENT_content_1 | OLD_AGENT_content_2;
|
|
307
|
+
}
|
|
308
|
+
interface QUESTIONNAIRE {
|
|
309
|
+
signal: "questionnaire";
|
|
310
|
+
content: {
|
|
311
|
+
status: unknown;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
type LayoutID = string | number;
|
|
315
|
+
interface LAYOUT {
|
|
316
|
+
signal: "layout";
|
|
317
|
+
content: {
|
|
318
|
+
type: "mount";
|
|
319
|
+
id: LayoutID;
|
|
320
|
+
panel: string;
|
|
321
|
+
props?: Record<string, unknown>;
|
|
322
|
+
zIndex?: number;
|
|
323
|
+
} | {
|
|
324
|
+
type: "update";
|
|
325
|
+
id: LayoutID;
|
|
326
|
+
props?: Record<string, unknown>;
|
|
327
|
+
zIndex?: number;
|
|
328
|
+
} | {
|
|
329
|
+
type: "unmount";
|
|
330
|
+
id: LayoutID;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
type AUDIO = {
|
|
334
|
+
signal: "audio";
|
|
335
|
+
content: number[];
|
|
336
|
+
command: "pcm";
|
|
337
|
+
} | {
|
|
338
|
+
signal: "audio";
|
|
339
|
+
content: number;
|
|
340
|
+
command: "sampleRate";
|
|
341
|
+
} | {
|
|
342
|
+
signal: "status";
|
|
343
|
+
content: "Connected";
|
|
344
|
+
} | {
|
|
345
|
+
signal: "audio";
|
|
346
|
+
command: "interrupted";
|
|
347
|
+
};
|
|
348
|
+
interface CV {
|
|
349
|
+
signal: "cv";
|
|
350
|
+
content: {
|
|
351
|
+
status: "user present" | "user leave";
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
interface MovementToUE {
|
|
355
|
+
signal: "osc";
|
|
356
|
+
content: {
|
|
357
|
+
host: string;
|
|
358
|
+
port: number;
|
|
359
|
+
message: [string, ...(string | number)[]];
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
type CLOUD_SOCKET_MSG = TTS | MIC | ASR | AGENT | OLD_ASR | OLD_AGENT | RATINGS | QUESTIONNAIRE | LAYOUT | AUDIO | CV | MovementToUE;
|
|
363
|
+
interface SendMessage_MiniGame {
|
|
364
|
+
request: "minigame";
|
|
365
|
+
userCtrl?: boolean;
|
|
366
|
+
content: {
|
|
367
|
+
type: "start" | "open" | "next" | "answer" | "rank";
|
|
368
|
+
quizId?: string;
|
|
369
|
+
ansId?: string;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
interface SendMessage_Layout {
|
|
373
|
+
request: "layout";
|
|
374
|
+
userCtrl?: boolean;
|
|
375
|
+
content: {
|
|
376
|
+
type: "duplicate_id" | "miss_panel_name" | "id_not_find" | "props_error";
|
|
377
|
+
} & Record<string, string | string[]>;
|
|
378
|
+
}
|
|
379
|
+
interface SendMessage_Audio_Init {
|
|
380
|
+
request: "audio";
|
|
381
|
+
userCtrl?: boolean;
|
|
382
|
+
command: "sampleRate";
|
|
383
|
+
content: number;
|
|
384
|
+
}
|
|
385
|
+
interface SendMessage_Audio_PCM {
|
|
386
|
+
request: "audio";
|
|
387
|
+
userCtrl?: boolean;
|
|
388
|
+
command: "pcm";
|
|
389
|
+
content: number[];
|
|
390
|
+
}
|
|
391
|
+
type SendMessage_Audio = SendMessage_Audio_Init | SendMessage_Audio_PCM;
|
|
392
|
+
interface SendMessage_Face {
|
|
393
|
+
request: "face_detect";
|
|
394
|
+
content: boolean;
|
|
395
|
+
}
|
|
396
|
+
type LandmarkResult = Landmark[][];
|
|
397
|
+
interface SendMessage_Pose {
|
|
398
|
+
request: "pose_detect";
|
|
399
|
+
content: LandmarkResult;
|
|
400
|
+
}
|
|
401
|
+
type SendMessage = {
|
|
402
|
+
request: "reset";
|
|
403
|
+
} | {
|
|
404
|
+
request: "skip";
|
|
405
|
+
} | SendMessage_Layout | SendMessage_MiniGame | SendMessage_Audio | SendMessage_Face | SendMessage_Pose;
|
|
406
|
+
|
|
407
|
+
interface AiiaProjectItemWithAvatar extends AiiaProjectItem {
|
|
408
|
+
avatar: {
|
|
409
|
+
name: string;
|
|
410
|
+
url: string;
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
declare enum MonitorDeviceState {
|
|
414
|
+
未響應 = 1,// 瀏覽器未在時間內回應狀態
|
|
415
|
+
等待授權 = 2,
|
|
416
|
+
已被拒絕 = 3,
|
|
417
|
+
VAD模組載入失敗 = 4,
|
|
418
|
+
可正常使用 = 5,
|
|
419
|
+
缺失該裝置 = 6,
|
|
420
|
+
沒有服務 = 7
|
|
421
|
+
}
|
|
422
|
+
declare enum UnrealState {
|
|
423
|
+
非預期的狀態 = 1,
|
|
424
|
+
未授權控制 = 2,
|
|
425
|
+
未啟動 = 3,// Unreal 未啟動
|
|
426
|
+
無服務 = 4,// Unreal 已啟動,但服務未就緒
|
|
427
|
+
可使用 = 5
|
|
428
|
+
}
|
|
429
|
+
interface MonitorResult {
|
|
430
|
+
mic: MonitorDeviceState;
|
|
431
|
+
camera: MonitorDeviceState;
|
|
432
|
+
}
|
|
433
|
+
interface MSG_TO_SERVER {
|
|
434
|
+
uuid: string;
|
|
435
|
+
cloud: SendMessage;
|
|
436
|
+
debug: null;
|
|
437
|
+
face: AnalysisResult;
|
|
438
|
+
pose: LandmarkResult;
|
|
439
|
+
monitor: MonitorResult;
|
|
440
|
+
audio: number | number[];
|
|
441
|
+
version: null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
declare class AiiaConfig {
|
|
445
|
+
private config;
|
|
446
|
+
get webserver(): (node_http.Server<any, any> | node_https.Server<any, any> | node_http2.Http2SecureServer<any, any, any, any> | node_http2.Http2Server<any, any, any, any>) | undefined;
|
|
447
|
+
get environment(): string;
|
|
448
|
+
get license(): string;
|
|
449
|
+
get note(): string | undefined;
|
|
450
|
+
get deviceName(): string | undefined;
|
|
451
|
+
get port(): number;
|
|
452
|
+
get ws_url(): string;
|
|
453
|
+
get worklet_url(): string;
|
|
454
|
+
get project(): {
|
|
455
|
+
specific: boolean;
|
|
456
|
+
} & Partial<AiiaProjectItem>;
|
|
457
|
+
get endPoint(): {
|
|
458
|
+
api: string;
|
|
459
|
+
socket: string;
|
|
460
|
+
};
|
|
461
|
+
get debug(): boolean | "all" | "none" | LoggerLevel[];
|
|
462
|
+
get mediaStream(): MediaStream | null | undefined;
|
|
463
|
+
get chunkTimeInSeconds(): number;
|
|
464
|
+
get llmSampleRate(): number;
|
|
465
|
+
get detection(): {
|
|
466
|
+
perSecond: number;
|
|
467
|
+
confidence: number;
|
|
468
|
+
};
|
|
469
|
+
get autoClearSubtitle(): {
|
|
470
|
+
userDelayTime: number;
|
|
471
|
+
aiiaDelayTime: number;
|
|
472
|
+
};
|
|
473
|
+
get eyeTrackEnable(): boolean;
|
|
474
|
+
get eyeTrackCorrection(): {
|
|
475
|
+
x_axis_px: number;
|
|
476
|
+
y_axis_px: number;
|
|
477
|
+
};
|
|
478
|
+
get avatartService(): boolean;
|
|
479
|
+
constructor(config: InitOptions);
|
|
480
|
+
private safeRead;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare const VERSION: string;
|
|
484
|
+
|
|
485
|
+
export { AiiaConfig as A, type BrowserInitOptions as B, type CLOUD_SOCKET_MSG as C, type LandmarkResult as L, type MSG_TO_SERVER as M, type NodeInitOptions as N, type SendMessage as S, UnrealState as U, VERSION as V, type MovementToUE as a, type LAYOUT as b, type AiiaProjectItemWithAvatar as c, type Vec2 as d, MonitorDeviceState as e, type AiiaProjectItem as f };
|
package/dist/aiia-worklet.js
CHANGED
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*
|
|
24
|
-
* UPDATA DATE: 2026/
|
|
24
|
+
* UPDATA DATE: 2026/6/18
|
|
25
25
|
*/
|
|
26
26
|
var A=Object.defineProperty;var y=(e,r,t)=>r in e?A(e,r,{enumerable:true,configurable:true,writable:true,value:t}):e[r]=t;var u=(e,r,t)=>y(e,typeof r!="symbol"?r+"":r,t);function h(e,r,t){if(r===t)return e;let n=t/r,a=e.length,o=Math.ceil(a*n),s=new Float32Array(o),c=1/n,i=0;for(let f=0;f<o;f++){let l=i|0,g=i-l,p=e[l],d=l+1<a?e[l+1]:p;s[f]=p+(d-p)*g,i+=c;}return s}function x(e){let r=e.reduce((a,o)=>a+o.length,0),t=new Float32Array(r),n=0;for(let a of e)t.set(a,n),n+=a.length;return t}function M(e,r,t=1){let n=r*t,a=e/r;return Math.ceil(n*a)}var m=class extends AudioWorkletProcessor{constructor(t){super();u(this,"inputBuffer");u(this,"inputBufferLength");u(this,"processChunkSize");u(this,"outputSampleRate");u(this,"originalSampleRate");this.inputBuffer=[],this.inputBufferLength=0;let{outputSampleRate:n,chunkTimeInSeconds:a}=Object.assign({outputSampleRate:16e3,chunkTimeInSeconds:1},t==null?void 0:t.processorOptions);this.originalSampleRate=sampleRate,this.outputSampleRate=n,this.processChunkSize=M(this.originalSampleRate,this.outputSampleRate,a);}process(t,n,a){let o=t[0][0];if(!o)return true;let s=new Float32Array(o);if(this.inputBuffer.push(s),this.inputBufferLength+=o.length,this.inputBufferLength>=this.processChunkSize){let c=x(this.inputBuffer);this.inputBuffer=[],this.inputBufferLength=0;let i=h(c,this.originalSampleRate,this.outputSampleRate);this.port.postMessage({float32:i,outputSampleRate:this.outputSampleRate},[i.buffer]);}return true}};registerProcessor("aiia-vad",m);})();
|