@goodganglabs/lipsync-wasm-v1 0.3.0

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.

Potentially problematic release.


This version of @goodganglabs/lipsync-wasm-v1 might be problematic. Click here for more details.

@@ -0,0 +1,1083 @@
1
+ /* @ts-self-types="./lipsync_wasm_v1.d.ts" */
2
+
3
+ /**
4
+ * Idle 상태에서 눈 깜빡임 + 미세 표정을 생성하는 구조체
5
+ *
6
+ * V2의 add_blinks 로직을 재활용하여, idle 상태에서도
7
+ * 자연스러운 표정 변화가 나오도록 한다.
8
+ */
9
+ export class IdleExpressionGenerator {
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ IdleExpressionGeneratorFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_idleexpressiongenerator_free(ptr, 0);
19
+ }
20
+ /**
21
+ * elapsed_time(초)에 해당하는 52-dim 블렌드쉐입 프레임 반환
22
+ * @param {number} elapsed_time
23
+ * @returns {Float32Array}
24
+ */
25
+ get_frame(elapsed_time) {
26
+ const ret = wasm.idleexpressiongenerator_get_frame(this.__wbg_ptr, elapsed_time);
27
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
28
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
29
+ return v1;
30
+ }
31
+ constructor() {
32
+ const ret = wasm.idleexpressiongenerator_new();
33
+ this.__wbg_ptr = ret >>> 0;
34
+ IdleExpressionGeneratorFinalization.register(this, this.__wbg_ptr, this);
35
+ return this;
36
+ }
37
+ /**
38
+ * 상태 초기화
39
+ */
40
+ reset() {
41
+ wasm.idleexpressiongenerator_reset(this.__wbg_ptr);
42
+ }
43
+ }
44
+ if (Symbol.dispose) IdleExpressionGenerator.prototype[Symbol.dispose] = IdleExpressionGenerator.prototype.free;
45
+
46
+ /**
47
+ * 메인 LipSync WASM 클래스
48
+ */
49
+ export class LipSyncWasm {
50
+ __destroy_into_raw() {
51
+ const ptr = this.__wbg_ptr;
52
+ this.__wbg_ptr = 0;
53
+ LipSyncWasmFinalization.unregister(this);
54
+ return ptr;
55
+ }
56
+ free() {
57
+ const ptr = this.__destroy_into_raw();
58
+ wasm.__wbg_lipsyncwasm_free(ptr, 0);
59
+ }
60
+ /**
61
+ * 배치 모드: ONNX 결과 조립 + 후처리
62
+ *
63
+ * phoneme_probs: ONNX 출력 (flatten, N * 61)
64
+ * @param {Float32Array} phoneme_probs
65
+ * @returns {any}
66
+ */
67
+ assemble_and_postprocess(phoneme_probs) {
68
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
69
+ const len0 = WASM_VECTOR_LEN;
70
+ const ret = wasm.lipsyncwasm_assemble_and_postprocess(this.__wbg_ptr, ptr0, len0);
71
+ if (ret[2]) {
72
+ throw takeFromExternrefTable0(ret[1]);
73
+ }
74
+ return takeFromExternrefTable0(ret[0]);
75
+ }
76
+ /**
77
+ * 프리셋 제거
78
+ */
79
+ clear_preset() {
80
+ wasm.lipsyncwasm_clear_preset(this.__wbg_ptr);
81
+ }
82
+ /**
83
+ * 스트리밍 모드 종료
84
+ */
85
+ end_streaming() {
86
+ wasm.lipsyncwasm_end_streaming(this.__wbg_ptr);
87
+ }
88
+ /**
89
+ * MFCC 추출 (JS에서 onnxruntime-web 추론에 사용)
90
+ * @param {Float32Array} audio
91
+ * @returns {Float32Array}
92
+ */
93
+ extract_mfcc(audio) {
94
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
95
+ const len0 = WASM_VECTOR_LEN;
96
+ const ret = wasm.lipsyncwasm_extract_mfcc(this.__wbg_ptr, ptr0, len0);
97
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
98
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
99
+ return v2;
100
+ }
101
+ /**
102
+ * 스트리밍: 오디오 청크에서 MFCC 추출
103
+ *
104
+ * 반환: flatten MFCC (N * 13)
105
+ * @param {Float32Array} audio
106
+ * @returns {Float32Array}
107
+ */
108
+ extract_mfcc_chunk(audio) {
109
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.lipsyncwasm_extract_mfcc_chunk(this.__wbg_ptr, ptr0, len0);
112
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
113
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
114
+ return v2;
115
+ }
116
+ /**
117
+ * 스트리밍: 오디오 청크를 입력받아 MFCC 추출 + 버퍼링
118
+ *
119
+ * 내부 버퍼에 MFCC를 축적하고, 30프레임 이상 도달 시
120
+ * MFCC 데이터를 반환 (JS에서 ONNX 추론 수행).
121
+ * @param {Float32Array} audio
122
+ * @returns {any}
123
+ */
124
+ feed_audio_chunk(audio) {
125
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ret = wasm.lipsyncwasm_feed_audio_chunk(this.__wbg_ptr, ptr0, len0);
128
+ if (ret[2]) {
129
+ throw takeFromExternrefTable0(ret[1]);
130
+ }
131
+ return takeFromExternrefTable0(ret[0]);
132
+ }
133
+ /**
134
+ * 스트리밍: ONNX 추론 결과로 블렌드쉐입 생성
135
+ *
136
+ * phoneme_probs: ONNX 출력 (flatten, N * num_classes)
137
+ * @param {Float32Array} phoneme_probs
138
+ * @param {number} num_classes
139
+ * @returns {any}
140
+ */
141
+ feed_onnx_result(phoneme_probs, num_classes) {
142
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ const ret = wasm.lipsyncwasm_feed_onnx_result(this.__wbg_ptr, ptr0, len0, num_classes);
145
+ if (ret[2]) {
146
+ throw takeFromExternrefTable0(ret[1]);
147
+ }
148
+ return takeFromExternrefTable0(ret[0]);
149
+ }
150
+ /**
151
+ * 스트리밍: 잔여 버퍼 플러시 (마지막 청크에서 호출)
152
+ * @returns {any}
153
+ */
154
+ flush_audio_buffer() {
155
+ const ret = wasm.lipsyncwasm_flush_audio_buffer(this.__wbg_ptr);
156
+ if (ret[2]) {
157
+ throw takeFromExternrefTable0(ret[1]);
158
+ }
159
+ return takeFromExternrefTable0(ret[0]);
160
+ }
161
+ /**
162
+ * 후보정 상태 조회
163
+ * @returns {boolean}
164
+ */
165
+ get_corrections_enabled() {
166
+ const ret = wasm.lipsyncwasm_get_corrections_enabled(this.__wbg_ptr);
167
+ return ret !== 0;
168
+ }
169
+ /**
170
+ * 특정 프레임의 블렌드쉐입 추출
171
+ * @param {any} result
172
+ * @param {number} frame_index
173
+ * @returns {Float32Array}
174
+ */
175
+ get_frame(result, frame_index) {
176
+ const ret = wasm.lipsyncwasm_get_frame(this.__wbg_ptr, result, frame_index);
177
+ if (ret[3]) {
178
+ throw takeFromExternrefTable0(ret[2]);
179
+ }
180
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
181
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
182
+ return v1;
183
+ }
184
+ /**
185
+ * 프레임 수 조회
186
+ * @returns {number}
187
+ */
188
+ get_frame_count() {
189
+ const ret = wasm.lipsyncwasm_get_frame_count(this.__wbg_ptr);
190
+ return ret >>> 0;
191
+ }
192
+ /**
193
+ * 내장 idle VRMA 원본 바이트 반환
194
+ * @returns {Uint8Array}
195
+ */
196
+ get_idle_vrma_bytes() {
197
+ const ret = wasm.lipsyncwasm_get_idle_vrma_bytes(this.__wbg_ptr);
198
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
199
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
200
+ return v1;
201
+ }
202
+ /**
203
+ * 내장 speaking VRMA 원본 바이트 반환
204
+ * @returns {Uint8Array}
205
+ */
206
+ get_speaking_vrma_bytes() {
207
+ const ret = wasm.lipsyncwasm_get_speaking_vrma_bytes(this.__wbg_ptr);
208
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
209
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
210
+ return v1;
211
+ }
212
+ /**
213
+ * 프리셋 로드 여부
214
+ * @returns {boolean}
215
+ */
216
+ has_preset() {
217
+ const ret = wasm.lipsyncwasm_has_preset(this.__wbg_ptr);
218
+ return ret !== 0;
219
+ }
220
+ /**
221
+ * 라이선스 검증 여부 조회
222
+ * @returns {boolean}
223
+ */
224
+ is_license_validated() {
225
+ const ret = wasm.lipsyncwasm_is_license_validated(this.__wbg_ptr);
226
+ return ret !== 0;
227
+ }
228
+ /**
229
+ * 스트리밍 모드 여부 조회
230
+ * @returns {boolean}
231
+ */
232
+ is_streaming() {
233
+ const ret = wasm.lipsyncwasm_is_streaming(this.__wbg_ptr);
234
+ return ret !== 0;
235
+ }
236
+ /**
237
+ * 내장 기본 프리셋 로드 (jc01)
238
+ */
239
+ load_default_preset() {
240
+ const ret = wasm.lipsyncwasm_load_default_preset(this.__wbg_ptr);
241
+ if (ret[1]) {
242
+ throw takeFromExternrefTable0(ret[0]);
243
+ }
244
+ }
245
+ /**
246
+ * 프리셋 애니메이션 로드
247
+ * @param {Float32Array} data
248
+ * @param {number} num_frames
249
+ * @param {number} num_dims
250
+ */
251
+ load_preset(data, num_frames, num_dims) {
252
+ const ptr0 = passArrayF32ToWasm0(data, wasm.__wbindgen_malloc);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ wasm.lipsyncwasm_load_preset(this.__wbg_ptr, ptr0, len0, num_frames, num_dims);
255
+ }
256
+ /**
257
+ * 새 LipSync 인스턴스 생성
258
+ */
259
+ constructor() {
260
+ const ret = wasm.lipsyncwasm_new();
261
+ if (ret[2]) {
262
+ throw takeFromExternrefTable0(ret[1]);
263
+ }
264
+ this.__wbg_ptr = ret[0] >>> 0;
265
+ LipSyncWasmFinalization.register(this, this.__wbg_ptr, this);
266
+ return this;
267
+ }
268
+ /**
269
+ * 배치 모드: ONNX 입력 준비 (MFCC 추출)
270
+ *
271
+ * JS에서 ONNX 추론 후 assemble_and_postprocess()로 전달.
272
+ * V1은 chunking 불필요 (가변 길이 MFCC → ONNX).
273
+ * @param {Float32Array} audio
274
+ * @returns {any}
275
+ */
276
+ prepare_onnx_input(audio) {
277
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
278
+ const len0 = WASM_VECTOR_LEN;
279
+ const ret = wasm.lipsyncwasm_prepare_onnx_input(this.__wbg_ptr, ptr0, len0);
280
+ if (ret[2]) {
281
+ throw takeFromExternrefTable0(ret[1]);
282
+ }
283
+ return takeFromExternrefTable0(ret[0]);
284
+ }
285
+ /**
286
+ * 오디오 처리 (휴리스틱 폴백 모드)
287
+ * @param {Float32Array} audio
288
+ * @returns {any}
289
+ */
290
+ process_audio(audio) {
291
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ret = wasm.lipsyncwasm_process_audio(this.__wbg_ptr, ptr0, len0);
294
+ if (ret[2]) {
295
+ throw takeFromExternrefTable0(ret[1]);
296
+ }
297
+ return takeFromExternrefTable0(ret[0]);
298
+ }
299
+ /**
300
+ * 오디오 + 프리셋 블렌딩 (휴리스틱 애니메이션 모드)
301
+ * @param {Float32Array} audio
302
+ * @returns {any}
303
+ */
304
+ process_audio_with_animation(audio) {
305
+ const ptr0 = passArrayF32ToWasm0(audio, wasm.__wbindgen_malloc);
306
+ const len0 = WASM_VECTOR_LEN;
307
+ const ret = wasm.lipsyncwasm_process_audio_with_animation(this.__wbg_ptr, ptr0, len0);
308
+ if (ret[2]) {
309
+ throw takeFromExternrefTable0(ret[1]);
310
+ }
311
+ return takeFromExternrefTable0(ret[0]);
312
+ }
313
+ /**
314
+ * 음소 확률에서 블렌드쉐입 생성 (ONNX 추론 결과 사용)
315
+ * @param {Float32Array} phoneme_probs
316
+ * @param {number} num_classes
317
+ * @returns {any}
318
+ */
319
+ process_phonemes(phoneme_probs, num_classes) {
320
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
321
+ const len0 = WASM_VECTOR_LEN;
322
+ const ret = wasm.lipsyncwasm_process_phonemes(this.__wbg_ptr, ptr0, len0, num_classes);
323
+ if (ret[2]) {
324
+ throw takeFromExternrefTable0(ret[1]);
325
+ }
326
+ return takeFromExternrefTable0(ret[0]);
327
+ }
328
+ /**
329
+ * 스트리밍: 음소 확률에서 블렌드쉐입 생성 (ONNX 추론 결과)
330
+ *
331
+ * OneEuroFilter가 시간 오프셋을 유지하여 청크 간 연속성 보장.
332
+ * @param {Float32Array} phoneme_probs
333
+ * @param {number} num_classes
334
+ * @returns {any}
335
+ */
336
+ process_phonemes_chunk(phoneme_probs, num_classes) {
337
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
338
+ const len0 = WASM_VECTOR_LEN;
339
+ const ret = wasm.lipsyncwasm_process_phonemes_chunk(this.__wbg_ptr, ptr0, len0, num_classes);
340
+ if (ret[2]) {
341
+ throw takeFromExternrefTable0(ret[1]);
342
+ }
343
+ return takeFromExternrefTable0(ret[0]);
344
+ }
345
+ /**
346
+ * 스트리밍: 음소 확률 + 프리셋 블렌딩
347
+ * @param {Float32Array} phoneme_probs
348
+ * @param {number} num_classes
349
+ * @returns {any}
350
+ */
351
+ process_phonemes_chunk_with_animation(phoneme_probs, num_classes) {
352
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
353
+ const len0 = WASM_VECTOR_LEN;
354
+ const ret = wasm.lipsyncwasm_process_phonemes_chunk_with_animation(this.__wbg_ptr, ptr0, len0, num_classes);
355
+ if (ret[2]) {
356
+ throw takeFromExternrefTable0(ret[1]);
357
+ }
358
+ return takeFromExternrefTable0(ret[0]);
359
+ }
360
+ /**
361
+ * 음소 확률 + 프리셋 블렌딩 (애니메이션 모드)
362
+ * @param {Float32Array} phoneme_probs
363
+ * @param {number} num_classes
364
+ * @returns {any}
365
+ */
366
+ process_phonemes_with_animation(phoneme_probs, num_classes) {
367
+ const ptr0 = passArrayF32ToWasm0(phoneme_probs, wasm.__wbindgen_malloc);
368
+ const len0 = WASM_VECTOR_LEN;
369
+ const ret = wasm.lipsyncwasm_process_phonemes_with_animation(this.__wbg_ptr, ptr0, len0, num_classes);
370
+ if (ret[2]) {
371
+ throw takeFromExternrefTable0(ret[1]);
372
+ }
373
+ return takeFromExternrefTable0(ret[0]);
374
+ }
375
+ /**
376
+ * 필터 상태 리셋
377
+ */
378
+ reset() {
379
+ wasm.lipsyncwasm_reset(this.__wbg_ptr);
380
+ }
381
+ /**
382
+ * 후보정 활성화/비활성화
383
+ * @param {boolean} enabled
384
+ */
385
+ set_corrections_enabled(enabled) {
386
+ wasm.lipsyncwasm_set_corrections_enabled(this.__wbg_ptr, enabled);
387
+ }
388
+ /**
389
+ * 라이선스 검증 완료 표시 (JS wrapper에서 get_onnx_model_licensed 성공 후 호출)
390
+ */
391
+ set_license_validated() {
392
+ wasm.lipsyncwasm_set_license_validated(this.__wbg_ptr);
393
+ }
394
+ /**
395
+ * 스트리밍 모드 시작
396
+ */
397
+ start_streaming() {
398
+ wasm.lipsyncwasm_start_streaming(this.__wbg_ptr);
399
+ }
400
+ }
401
+ if (Symbol.dispose) LipSyncWasm.prototype[Symbol.dispose] = LipSyncWasm.prototype.free;
402
+
403
+ /**
404
+ * RMS 에너지 기반 음성 활동 감지기 (V1/V2 공통)
405
+ *
406
+ * 마이크 스트리밍 시 말하는 중인지 판단하여
407
+ * idle<->speaking 본 애니메이션 전환을 제어한다.
408
+ */
409
+ export class VoiceActivityDetector {
410
+ __destroy_into_raw() {
411
+ const ptr = this.__wbg_ptr;
412
+ this.__wbg_ptr = 0;
413
+ VoiceActivityDetectorFinalization.unregister(this);
414
+ return ptr;
415
+ }
416
+ free() {
417
+ const ptr = this.__destroy_into_raw();
418
+ wasm.__wbg_voiceactivitydetector_free(ptr, 0);
419
+ }
420
+ /**
421
+ * 오디오 샘플을 입력받아 speaking 여부를 반환
422
+ *
423
+ * RMS 에너지 > threshold -> speaking, 아니면 hold_time 이후 silent
424
+ * @param {Float32Array} samples
425
+ * @returns {boolean}
426
+ */
427
+ feed_audio(samples) {
428
+ const ptr0 = passArrayF32ToWasm0(samples, wasm.__wbindgen_malloc);
429
+ const len0 = WASM_VECTOR_LEN;
430
+ const ret = wasm.voiceactivitydetector_feed_audio(this.__wbg_ptr, ptr0, len0);
431
+ return ret !== 0;
432
+ }
433
+ /**
434
+ * 현재 speaking 상태 조회
435
+ * @returns {boolean}
436
+ */
437
+ is_speaking() {
438
+ const ret = wasm.voiceactivitydetector_is_speaking(this.__wbg_ptr);
439
+ return ret !== 0;
440
+ }
441
+ /**
442
+ * @param {number} threshold
443
+ * @param {number} hold_time
444
+ */
445
+ constructor(threshold, hold_time) {
446
+ const ret = wasm.voiceactivitydetector_new(threshold, hold_time);
447
+ this.__wbg_ptr = ret >>> 0;
448
+ VoiceActivityDetectorFinalization.register(this, this.__wbg_ptr, this);
449
+ return this;
450
+ }
451
+ /**
452
+ * 상태 초기화
453
+ */
454
+ reset() {
455
+ wasm.voiceactivitydetector_reset(this.__wbg_ptr);
456
+ }
457
+ /**
458
+ * hold_time 변경
459
+ * @param {number} hold_time
460
+ */
461
+ set_hold_time(hold_time) {
462
+ wasm.voiceactivitydetector_set_hold_time(this.__wbg_ptr, hold_time);
463
+ }
464
+ /**
465
+ * RMS 임계값 변경
466
+ * @param {number} threshold
467
+ */
468
+ set_threshold(threshold) {
469
+ wasm.voiceactivitydetector_set_threshold(this.__wbg_ptr, threshold);
470
+ }
471
+ }
472
+ if (Symbol.dispose) VoiceActivityDetector.prototype[Symbol.dispose] = VoiceActivityDetector.prototype.free;
473
+
474
+ /**
475
+ * [Deprecated] 구 API — 라이선스 없이 모델 접근 불가
476
+ *
477
+ * get_onnx_model_licensed(token, timestamp)를 사용하세요.
478
+ * @returns {Uint8Array}
479
+ */
480
+ export function get_onnx_model() {
481
+ const ret = wasm.get_onnx_model();
482
+ if (ret[3]) {
483
+ throw takeFromExternrefTable0(ret[2]);
484
+ }
485
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
486
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
487
+ return v1;
488
+ }
489
+
490
+ /**
491
+ * 라이선스 검증 + ONNX 모델 복호화 (원자적 실행)
492
+ *
493
+ * Ed25519 서명 검증 통과 후에만 AES-256-GCM 복호화 수행.
494
+ *
495
+ * # Arguments
496
+ * * `token` - 서버에서 발급받은 라이선스 토큰 (EdDSA 서명)
497
+ * * `current_timestamp_secs` - 현재 Unix timestamp (초)
498
+ * @param {string} token
499
+ * @param {number} current_timestamp_secs
500
+ * @returns {Uint8Array}
501
+ */
502
+ export function get_onnx_model_licensed(token, current_timestamp_secs) {
503
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
504
+ const len0 = WASM_VECTOR_LEN;
505
+ const ret = wasm.get_onnx_model_licensed(ptr0, len0, current_timestamp_secs);
506
+ if (ret[3]) {
507
+ throw takeFromExternrefTable0(ret[2]);
508
+ }
509
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
510
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
511
+ return v2;
512
+ }
513
+
514
+ /**
515
+ * WASM 초기화 시 panic hook 설정
516
+ */
517
+ export function start() {
518
+ wasm.start();
519
+ }
520
+
521
+ function __wbg_get_imports() {
522
+ const import0 = {
523
+ __proto__: null,
524
+ __wbg_Error_ecbf49c1b9d07c30: function(arg0, arg1) {
525
+ const ret = Error(getStringFromWasm0(arg0, arg1));
526
+ return ret;
527
+ },
528
+ __wbg_Number_7da99b0afe51b89a: function(arg0) {
529
+ const ret = Number(arg0);
530
+ return ret;
531
+ },
532
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
533
+ const ret = String(arg1);
534
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
535
+ const len1 = WASM_VECTOR_LEN;
536
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
537
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
538
+ },
539
+ __wbg___wbindgen_boolean_get_4a348b369b009243: function(arg0) {
540
+ const v = arg0;
541
+ const ret = typeof(v) === 'boolean' ? v : undefined;
542
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
543
+ },
544
+ __wbg___wbindgen_debug_string_43c7ccb034739216: function(arg0, arg1) {
545
+ const ret = debugString(arg1);
546
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
547
+ const len1 = WASM_VECTOR_LEN;
548
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
549
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
550
+ },
551
+ __wbg___wbindgen_in_035107858ad0083e: function(arg0, arg1) {
552
+ const ret = arg0 in arg1;
553
+ return ret;
554
+ },
555
+ __wbg___wbindgen_is_function_18bea6e84080c016: function(arg0) {
556
+ const ret = typeof(arg0) === 'function';
557
+ return ret;
558
+ },
559
+ __wbg___wbindgen_is_object_8d3fac158b36498d: function(arg0) {
560
+ const val = arg0;
561
+ const ret = typeof(val) === 'object' && val !== null;
562
+ return ret;
563
+ },
564
+ __wbg___wbindgen_is_undefined_4a711ea9d2e1ef93: function(arg0) {
565
+ const ret = arg0 === undefined;
566
+ return ret;
567
+ },
568
+ __wbg___wbindgen_jsval_loose_eq_1a2067dfb025b5ec: function(arg0, arg1) {
569
+ const ret = arg0 == arg1;
570
+ return ret;
571
+ },
572
+ __wbg___wbindgen_number_get_eed4462ef92e1bed: function(arg0, arg1) {
573
+ const obj = arg1;
574
+ const ret = typeof(obj) === 'number' ? obj : undefined;
575
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
576
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
577
+ },
578
+ __wbg___wbindgen_string_get_d09f733449cbf7a2: function(arg0, arg1) {
579
+ const obj = arg1;
580
+ const ret = typeof(obj) === 'string' ? obj : undefined;
581
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
582
+ var len1 = WASM_VECTOR_LEN;
583
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
584
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
585
+ },
586
+ __wbg___wbindgen_throw_df03e93053e0f4bc: function(arg0, arg1) {
587
+ throw new Error(getStringFromWasm0(arg0, arg1));
588
+ },
589
+ __wbg_call_df7a43aecab856a8: function() { return handleError(function (arg0, arg1) {
590
+ const ret = arg0.call(arg1);
591
+ return ret;
592
+ }, arguments); },
593
+ __wbg_debug_5cd215874b9b39cc: function(arg0) {
594
+ console.debug(arg0);
595
+ },
596
+ __wbg_done_0ad70482cae88a68: function(arg0) {
597
+ const ret = arg0.done;
598
+ return ret;
599
+ },
600
+ __wbg_error_51679600615c775d: function(arg0) {
601
+ console.error(arg0);
602
+ },
603
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
604
+ let deferred0_0;
605
+ let deferred0_1;
606
+ try {
607
+ deferred0_0 = arg0;
608
+ deferred0_1 = arg1;
609
+ console.error(getStringFromWasm0(arg0, arg1));
610
+ } finally {
611
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
612
+ }
613
+ },
614
+ __wbg_get_6f5cf69c8f3f094a: function() { return handleError(function (arg0, arg1) {
615
+ const ret = Reflect.get(arg0, arg1);
616
+ return ret;
617
+ }, arguments); },
618
+ __wbg_get_unchecked_3de5bfaaea65f86b: function(arg0, arg1) {
619
+ const ret = arg0[arg1 >>> 0];
620
+ return ret;
621
+ },
622
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
623
+ const ret = arg0[arg1];
624
+ return ret;
625
+ },
626
+ __wbg_info_3039b9f214340fcd: function(arg0) {
627
+ console.info(arg0);
628
+ },
629
+ __wbg_instanceof_ArrayBuffer_d8e4e51f1cf7287a: function(arg0) {
630
+ let result;
631
+ try {
632
+ result = arg0 instanceof ArrayBuffer;
633
+ } catch (_) {
634
+ result = false;
635
+ }
636
+ const ret = result;
637
+ return ret;
638
+ },
639
+ __wbg_instanceof_Uint8Array_6e48d83da6091cc8: function(arg0) {
640
+ let result;
641
+ try {
642
+ result = arg0 instanceof Uint8Array;
643
+ } catch (_) {
644
+ result = false;
645
+ }
646
+ const ret = result;
647
+ return ret;
648
+ },
649
+ __wbg_instanceof_Window_0cc62e4f32542cc4: function(arg0) {
650
+ let result;
651
+ try {
652
+ result = arg0 instanceof Window;
653
+ } catch (_) {
654
+ result = false;
655
+ }
656
+ const ret = result;
657
+ return ret;
658
+ },
659
+ __wbg_isArray_2efa5973cef6ec32: function(arg0) {
660
+ const ret = Array.isArray(arg0);
661
+ return ret;
662
+ },
663
+ __wbg_isSafeInteger_6709fb28be12d738: function(arg0) {
664
+ const ret = Number.isSafeInteger(arg0);
665
+ return ret;
666
+ },
667
+ __wbg_iterator_e77d2b7575cca5a7: function() {
668
+ const ret = Symbol.iterator;
669
+ return ret;
670
+ },
671
+ __wbg_length_00dd7227fd4626ad: function(arg0) {
672
+ const ret = arg0.length;
673
+ return ret;
674
+ },
675
+ __wbg_length_5e07cf181b2745fb: function(arg0) {
676
+ const ret = arg0.length;
677
+ return ret;
678
+ },
679
+ __wbg_log_91f1dd1dfd5a4ae8: function(arg0) {
680
+ console.log(arg0);
681
+ },
682
+ __wbg_new_227d7c05414eb861: function() {
683
+ const ret = new Error();
684
+ return ret;
685
+ },
686
+ __wbg_new_62f131e968c83d75: function() {
687
+ const ret = new Object();
688
+ return ret;
689
+ },
690
+ __wbg_new_66075f8c2ea6575e: function() {
691
+ const ret = new Array();
692
+ return ret;
693
+ },
694
+ __wbg_new_a0479da6258a0d71: function(arg0) {
695
+ const ret = new Uint8Array(arg0);
696
+ return ret;
697
+ },
698
+ __wbg_next_5428439dfc1d0362: function() { return handleError(function (arg0) {
699
+ const ret = arg0.next();
700
+ return ret;
701
+ }, arguments); },
702
+ __wbg_next_d314789a105729f3: function(arg0) {
703
+ const ret = arg0.next;
704
+ return ret;
705
+ },
706
+ __wbg_now_75e4393dab77b7a8: function(arg0) {
707
+ const ret = arg0.now();
708
+ return ret;
709
+ },
710
+ __wbg_performance_e773cd099222a8b1: function(arg0) {
711
+ const ret = arg0.performance;
712
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
713
+ },
714
+ __wbg_prototypesetcall_d1a7133bc8d83aa9: function(arg0, arg1, arg2) {
715
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
716
+ },
717
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
718
+ arg0[arg1] = arg2;
719
+ },
720
+ __wbg_set_7bf9e2df46e7632c: function(arg0, arg1, arg2) {
721
+ arg0[arg1 >>> 0] = arg2;
722
+ },
723
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
724
+ const ret = arg1.stack;
725
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
726
+ const len1 = WASM_VECTOR_LEN;
727
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
728
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
729
+ },
730
+ __wbg_static_accessor_GLOBAL_THIS_6614f2f4998e3c4c: function() {
731
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
732
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
733
+ },
734
+ __wbg_static_accessor_GLOBAL_d8e8a2fefe80bc1d: function() {
735
+ const ret = typeof global === 'undefined' ? null : global;
736
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
737
+ },
738
+ __wbg_static_accessor_SELF_e29eaf7c465526b1: function() {
739
+ const ret = typeof self === 'undefined' ? null : self;
740
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
741
+ },
742
+ __wbg_static_accessor_WINDOW_66e7ca3eef30585a: function() {
743
+ const ret = typeof window === 'undefined' ? null : window;
744
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
745
+ },
746
+ __wbg_value_414b42ce7b3eca22: function(arg0) {
747
+ const ret = arg0.value;
748
+ return ret;
749
+ },
750
+ __wbg_warn_52ab87a85aca283f: function(arg0) {
751
+ console.warn(arg0);
752
+ },
753
+ __wbindgen_cast_0000000000000001: function(arg0) {
754
+ // Cast intrinsic for `F64 -> Externref`.
755
+ const ret = arg0;
756
+ return ret;
757
+ },
758
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
759
+ // Cast intrinsic for `Ref(String) -> Externref`.
760
+ const ret = getStringFromWasm0(arg0, arg1);
761
+ return ret;
762
+ },
763
+ __wbindgen_init_externref_table: function() {
764
+ const table = wasm.__wbindgen_externrefs;
765
+ const offset = table.grow(4);
766
+ table.set(0, undefined);
767
+ table.set(offset + 0, undefined);
768
+ table.set(offset + 1, null);
769
+ table.set(offset + 2, true);
770
+ table.set(offset + 3, false);
771
+ },
772
+ };
773
+ return {
774
+ __proto__: null,
775
+ "./lipsync_wasm_v1_bg.js": import0,
776
+ };
777
+ }
778
+
779
+ const IdleExpressionGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
780
+ ? { register: () => {}, unregister: () => {} }
781
+ : new FinalizationRegistry(ptr => wasm.__wbg_idleexpressiongenerator_free(ptr >>> 0, 1));
782
+ const LipSyncWasmFinalization = (typeof FinalizationRegistry === 'undefined')
783
+ ? { register: () => {}, unregister: () => {} }
784
+ : new FinalizationRegistry(ptr => wasm.__wbg_lipsyncwasm_free(ptr >>> 0, 1));
785
+ const VoiceActivityDetectorFinalization = (typeof FinalizationRegistry === 'undefined')
786
+ ? { register: () => {}, unregister: () => {} }
787
+ : new FinalizationRegistry(ptr => wasm.__wbg_voiceactivitydetector_free(ptr >>> 0, 1));
788
+
789
+ function addToExternrefTable0(obj) {
790
+ const idx = wasm.__externref_table_alloc();
791
+ wasm.__wbindgen_externrefs.set(idx, obj);
792
+ return idx;
793
+ }
794
+
795
+ function debugString(val) {
796
+ // primitive types
797
+ const type = typeof val;
798
+ if (type == 'number' || type == 'boolean' || val == null) {
799
+ return `${val}`;
800
+ }
801
+ if (type == 'string') {
802
+ return `"${val}"`;
803
+ }
804
+ if (type == 'symbol') {
805
+ const description = val.description;
806
+ if (description == null) {
807
+ return 'Symbol';
808
+ } else {
809
+ return `Symbol(${description})`;
810
+ }
811
+ }
812
+ if (type == 'function') {
813
+ const name = val.name;
814
+ if (typeof name == 'string' && name.length > 0) {
815
+ return `Function(${name})`;
816
+ } else {
817
+ return 'Function';
818
+ }
819
+ }
820
+ // objects
821
+ if (Array.isArray(val)) {
822
+ const length = val.length;
823
+ let debug = '[';
824
+ if (length > 0) {
825
+ debug += debugString(val[0]);
826
+ }
827
+ for(let i = 1; i < length; i++) {
828
+ debug += ', ' + debugString(val[i]);
829
+ }
830
+ debug += ']';
831
+ return debug;
832
+ }
833
+ // Test for built-in
834
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
835
+ let className;
836
+ if (builtInMatches && builtInMatches.length > 1) {
837
+ className = builtInMatches[1];
838
+ } else {
839
+ // Failed to match the standard '[object ClassName]'
840
+ return toString.call(val);
841
+ }
842
+ if (className == 'Object') {
843
+ // we're a user defined class or Object
844
+ // JSON.stringify avoids problems with cycles, and is generally much
845
+ // easier than looping through ownProperties of `val`.
846
+ try {
847
+ return 'Object(' + JSON.stringify(val) + ')';
848
+ } catch (_) {
849
+ return 'Object';
850
+ }
851
+ }
852
+ // errors
853
+ if (val instanceof Error) {
854
+ return `${val.name}: ${val.message}\n${val.stack}`;
855
+ }
856
+ // TODO we could test for more things here, like `Set`s and `Map`s.
857
+ return className;
858
+ }
859
+
860
+ function getArrayF32FromWasm0(ptr, len) {
861
+ ptr = ptr >>> 0;
862
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
863
+ }
864
+
865
+ function getArrayU8FromWasm0(ptr, len) {
866
+ ptr = ptr >>> 0;
867
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
868
+ }
869
+
870
+ let cachedDataViewMemory0 = null;
871
+ function getDataViewMemory0() {
872
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
873
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
874
+ }
875
+ return cachedDataViewMemory0;
876
+ }
877
+
878
+ let cachedFloat32ArrayMemory0 = null;
879
+ function getFloat32ArrayMemory0() {
880
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
881
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
882
+ }
883
+ return cachedFloat32ArrayMemory0;
884
+ }
885
+
886
+ function getStringFromWasm0(ptr, len) {
887
+ ptr = ptr >>> 0;
888
+ return decodeText(ptr, len);
889
+ }
890
+
891
+ let cachedUint8ArrayMemory0 = null;
892
+ function getUint8ArrayMemory0() {
893
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
894
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
895
+ }
896
+ return cachedUint8ArrayMemory0;
897
+ }
898
+
899
+ function handleError(f, args) {
900
+ try {
901
+ return f.apply(this, args);
902
+ } catch (e) {
903
+ const idx = addToExternrefTable0(e);
904
+ wasm.__wbindgen_exn_store(idx);
905
+ }
906
+ }
907
+
908
+ function isLikeNone(x) {
909
+ return x === undefined || x === null;
910
+ }
911
+
912
+ function passArrayF32ToWasm0(arg, malloc) {
913
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
914
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
915
+ WASM_VECTOR_LEN = arg.length;
916
+ return ptr;
917
+ }
918
+
919
+ function passStringToWasm0(arg, malloc, realloc) {
920
+ if (realloc === undefined) {
921
+ const buf = cachedTextEncoder.encode(arg);
922
+ const ptr = malloc(buf.length, 1) >>> 0;
923
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
924
+ WASM_VECTOR_LEN = buf.length;
925
+ return ptr;
926
+ }
927
+
928
+ let len = arg.length;
929
+ let ptr = malloc(len, 1) >>> 0;
930
+
931
+ const mem = getUint8ArrayMemory0();
932
+
933
+ let offset = 0;
934
+
935
+ for (; offset < len; offset++) {
936
+ const code = arg.charCodeAt(offset);
937
+ if (code > 0x7F) break;
938
+ mem[ptr + offset] = code;
939
+ }
940
+ if (offset !== len) {
941
+ if (offset !== 0) {
942
+ arg = arg.slice(offset);
943
+ }
944
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
945
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
946
+ const ret = cachedTextEncoder.encodeInto(arg, view);
947
+
948
+ offset += ret.written;
949
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
950
+ }
951
+
952
+ WASM_VECTOR_LEN = offset;
953
+ return ptr;
954
+ }
955
+
956
+ function takeFromExternrefTable0(idx) {
957
+ const value = wasm.__wbindgen_externrefs.get(idx);
958
+ wasm.__externref_table_dealloc(idx);
959
+ return value;
960
+ }
961
+
962
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
963
+ cachedTextDecoder.decode();
964
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
965
+ let numBytesDecoded = 0;
966
+ function decodeText(ptr, len) {
967
+ numBytesDecoded += len;
968
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
969
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
970
+ cachedTextDecoder.decode();
971
+ numBytesDecoded = len;
972
+ }
973
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
974
+ }
975
+
976
+ const cachedTextEncoder = new TextEncoder();
977
+
978
+ if (!('encodeInto' in cachedTextEncoder)) {
979
+ cachedTextEncoder.encodeInto = function (arg, view) {
980
+ const buf = cachedTextEncoder.encode(arg);
981
+ view.set(buf);
982
+ return {
983
+ read: arg.length,
984
+ written: buf.length
985
+ };
986
+ };
987
+ }
988
+
989
+ let WASM_VECTOR_LEN = 0;
990
+
991
+ let wasmModule, wasm;
992
+ function __wbg_finalize_init(instance, module) {
993
+ wasm = instance.exports;
994
+ wasmModule = module;
995
+ cachedDataViewMemory0 = null;
996
+ cachedFloat32ArrayMemory0 = null;
997
+ cachedUint8ArrayMemory0 = null;
998
+ wasm.__wbindgen_start();
999
+ return wasm;
1000
+ }
1001
+
1002
+ async function __wbg_load(module, imports) {
1003
+ if (typeof Response === 'function' && module instanceof Response) {
1004
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1005
+ try {
1006
+ return await WebAssembly.instantiateStreaming(module, imports);
1007
+ } catch (e) {
1008
+ const validResponse = module.ok && expectedResponseType(module.type);
1009
+
1010
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1011
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1012
+
1013
+ } else { throw e; }
1014
+ }
1015
+ }
1016
+
1017
+ const bytes = await module.arrayBuffer();
1018
+ return await WebAssembly.instantiate(bytes, imports);
1019
+ } else {
1020
+ const instance = await WebAssembly.instantiate(module, imports);
1021
+
1022
+ if (instance instanceof WebAssembly.Instance) {
1023
+ return { instance, module };
1024
+ } else {
1025
+ return instance;
1026
+ }
1027
+ }
1028
+
1029
+ function expectedResponseType(type) {
1030
+ switch (type) {
1031
+ case 'basic': case 'cors': case 'default': return true;
1032
+ }
1033
+ return false;
1034
+ }
1035
+ }
1036
+
1037
+ function initSync(module) {
1038
+ if (wasm !== undefined) return wasm;
1039
+
1040
+
1041
+ if (module !== undefined) {
1042
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1043
+ ({module} = module)
1044
+ } else {
1045
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1046
+ }
1047
+ }
1048
+
1049
+ const imports = __wbg_get_imports();
1050
+ if (!(module instanceof WebAssembly.Module)) {
1051
+ module = new WebAssembly.Module(module);
1052
+ }
1053
+ const instance = new WebAssembly.Instance(module, imports);
1054
+ return __wbg_finalize_init(instance, module);
1055
+ }
1056
+
1057
+ async function __wbg_init(module_or_path) {
1058
+ if (wasm !== undefined) return wasm;
1059
+
1060
+
1061
+ if (module_or_path !== undefined) {
1062
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1063
+ ({module_or_path} = module_or_path)
1064
+ } else {
1065
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1066
+ }
1067
+ }
1068
+
1069
+ if (module_or_path === undefined) {
1070
+ module_or_path = new URL('lipsync_wasm_v1_bg.wasm', import.meta.url);
1071
+ }
1072
+ const imports = __wbg_get_imports();
1073
+
1074
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1075
+ module_or_path = fetch(module_or_path);
1076
+ }
1077
+
1078
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1079
+
1080
+ return __wbg_finalize_init(instance, module);
1081
+ }
1082
+
1083
+ export { initSync, __wbg_init as default };