radames commited on
Commit
63a6b51
β€’
1 Parent(s): 613b4da

new ui files

Browse files
app-5d6e90e818ed37ea.js DELETED
@@ -1,841 +0,0 @@
1
- let wasm;
2
-
3
- const heap = new Array(128).fill(undefined);
4
-
5
- heap.push(undefined, null, true, false);
6
-
7
- function getObject(idx) { return heap[idx]; }
8
-
9
- let heap_next = heap.length;
10
-
11
- function dropObject(idx) {
12
- if (idx < 132) return;
13
- heap[idx] = heap_next;
14
- heap_next = idx;
15
- }
16
-
17
- function takeObject(idx) {
18
- const ret = getObject(idx);
19
- dropObject(idx);
20
- return ret;
21
- }
22
-
23
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
24
-
25
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
26
-
27
- let cachedUint8Memory0 = null;
28
-
29
- function getUint8Memory0() {
30
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
31
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
32
- }
33
- return cachedUint8Memory0;
34
- }
35
-
36
- function getStringFromWasm0(ptr, len) {
37
- ptr = ptr >>> 0;
38
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
39
- }
40
-
41
- function addHeapObject(obj) {
42
- if (heap_next === heap.length) heap.push(heap.length + 1);
43
- const idx = heap_next;
44
- heap_next = heap[idx];
45
-
46
- heap[idx] = obj;
47
- return idx;
48
- }
49
-
50
- let WASM_VECTOR_LEN = 0;
51
-
52
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
53
-
54
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
55
- ? function (arg, view) {
56
- return cachedTextEncoder.encodeInto(arg, view);
57
- }
58
- : function (arg, view) {
59
- const buf = cachedTextEncoder.encode(arg);
60
- view.set(buf);
61
- return {
62
- read: arg.length,
63
- written: buf.length
64
- };
65
- });
66
-
67
- function passStringToWasm0(arg, malloc, realloc) {
68
-
69
- if (realloc === undefined) {
70
- const buf = cachedTextEncoder.encode(arg);
71
- const ptr = malloc(buf.length, 1) >>> 0;
72
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
73
- WASM_VECTOR_LEN = buf.length;
74
- return ptr;
75
- }
76
-
77
- let len = arg.length;
78
- let ptr = malloc(len, 1) >>> 0;
79
-
80
- const mem = getUint8Memory0();
81
-
82
- let offset = 0;
83
-
84
- for (; offset < len; offset++) {
85
- const code = arg.charCodeAt(offset);
86
- if (code > 0x7F) break;
87
- mem[ptr + offset] = code;
88
- }
89
-
90
- if (offset !== len) {
91
- if (offset !== 0) {
92
- arg = arg.slice(offset);
93
- }
94
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
95
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
96
- const ret = encodeString(arg, view);
97
-
98
- offset += ret.written;
99
- }
100
-
101
- WASM_VECTOR_LEN = offset;
102
- return ptr;
103
- }
104
-
105
- function isLikeNone(x) {
106
- return x === undefined || x === null;
107
- }
108
-
109
- let cachedInt32Memory0 = null;
110
-
111
- function getInt32Memory0() {
112
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
113
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
114
- }
115
- return cachedInt32Memory0;
116
- }
117
-
118
- function debugString(val) {
119
- // primitive types
120
- const type = typeof val;
121
- if (type == 'number' || type == 'boolean' || val == null) {
122
- return `${val}`;
123
- }
124
- if (type == 'string') {
125
- return `"${val}"`;
126
- }
127
- if (type == 'symbol') {
128
- const description = val.description;
129
- if (description == null) {
130
- return 'Symbol';
131
- } else {
132
- return `Symbol(${description})`;
133
- }
134
- }
135
- if (type == 'function') {
136
- const name = val.name;
137
- if (typeof name == 'string' && name.length > 0) {
138
- return `Function(${name})`;
139
- } else {
140
- return 'Function';
141
- }
142
- }
143
- // objects
144
- if (Array.isArray(val)) {
145
- const length = val.length;
146
- let debug = '[';
147
- if (length > 0) {
148
- debug += debugString(val[0]);
149
- }
150
- for(let i = 1; i < length; i++) {
151
- debug += ', ' + debugString(val[i]);
152
- }
153
- debug += ']';
154
- return debug;
155
- }
156
- // Test for built-in
157
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
158
- let className;
159
- if (builtInMatches.length > 1) {
160
- className = builtInMatches[1];
161
- } else {
162
- // Failed to match the standard '[object ClassName]'
163
- return toString.call(val);
164
- }
165
- if (className == 'Object') {
166
- // we're a user defined class or Object
167
- // JSON.stringify avoids problems with cycles, and is generally much
168
- // easier than looping through ownProperties of `val`.
169
- try {
170
- return 'Object(' + JSON.stringify(val) + ')';
171
- } catch (_) {
172
- return 'Object';
173
- }
174
- }
175
- // errors
176
- if (val instanceof Error) {
177
- return `${val.name}: ${val.message}\n${val.stack}`;
178
- }
179
- // TODO we could test for more things here, like `Set`s and `Map`s.
180
- return className;
181
- }
182
-
183
- function makeClosure(arg0, arg1, dtor, f) {
184
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
185
- const real = (...args) => {
186
- // First up with a closure we increment the internal reference
187
- // count. This ensures that the Rust closure environment won't
188
- // be deallocated while we're invoking it.
189
- state.cnt++;
190
- try {
191
- return f(state.a, state.b, ...args);
192
- } finally {
193
- if (--state.cnt === 0) {
194
- wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b);
195
- state.a = 0;
196
-
197
- }
198
- }
199
- };
200
- real.original = state;
201
-
202
- return real;
203
- }
204
- function __wbg_adapter_20(arg0, arg1, arg2) {
205
- wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd9d359bec27afc01(arg0, arg1, addHeapObject(arg2));
206
- }
207
-
208
- function makeMutClosure(arg0, arg1, dtor, f) {
209
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
210
- const real = (...args) => {
211
- // First up with a closure we increment the internal reference
212
- // count. This ensures that the Rust closure environment won't
213
- // be deallocated while we're invoking it.
214
- state.cnt++;
215
- const a = state.a;
216
- state.a = 0;
217
- try {
218
- return f(a, state.b, ...args);
219
- } finally {
220
- if (--state.cnt === 0) {
221
- wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
222
-
223
- } else {
224
- state.a = a;
225
- }
226
- }
227
- };
228
- real.original = state;
229
-
230
- return real;
231
- }
232
-
233
- let stack_pointer = 128;
234
-
235
- function addBorrowedObject(obj) {
236
- if (stack_pointer == 1) throw new Error('out of js stack');
237
- heap[--stack_pointer] = obj;
238
- return stack_pointer;
239
- }
240
- function __wbg_adapter_23(arg0, arg1, arg2) {
241
- try {
242
- wasm._dyn_core__ops__function__FnMut___A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hadab26222cba6f84(arg0, arg1, addBorrowedObject(arg2));
243
- } finally {
244
- heap[stack_pointer++] = undefined;
245
- }
246
- }
247
-
248
- function __wbg_adapter_26(arg0, arg1, arg2) {
249
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfc3f0e78cf729c36(arg0, arg1, addHeapObject(arg2));
250
- }
251
-
252
- let cachedUint32Memory0 = null;
253
-
254
- function getUint32Memory0() {
255
- if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
256
- cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
257
- }
258
- return cachedUint32Memory0;
259
- }
260
-
261
- function getArrayJsValueFromWasm0(ptr, len) {
262
- ptr = ptr >>> 0;
263
- const mem = getUint32Memory0();
264
- const slice = mem.subarray(ptr / 4, ptr / 4 + len);
265
- const result = [];
266
- for (let i = 0; i < slice.length; i++) {
267
- result.push(takeObject(slice[i]));
268
- }
269
- return result;
270
- }
271
-
272
- function handleError(f, args) {
273
- try {
274
- return f.apply(this, args);
275
- } catch (e) {
276
- wasm.__wbindgen_exn_store(addHeapObject(e));
277
- }
278
- }
279
-
280
- async function __wbg_load(module, imports) {
281
- if (typeof Response === 'function' && module instanceof Response) {
282
- if (typeof WebAssembly.instantiateStreaming === 'function') {
283
- try {
284
- return await WebAssembly.instantiateStreaming(module, imports);
285
-
286
- } catch (e) {
287
- if (module.headers.get('Content-Type') != 'application/wasm') {
288
- 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);
289
-
290
- } else {
291
- throw e;
292
- }
293
- }
294
- }
295
-
296
- const bytes = await module.arrayBuffer();
297
- return await WebAssembly.instantiate(bytes, imports);
298
-
299
- } else {
300
- const instance = await WebAssembly.instantiate(module, imports);
301
-
302
- if (instance instanceof WebAssembly.Instance) {
303
- return { instance, module };
304
-
305
- } else {
306
- return instance;
307
- }
308
- }
309
- }
310
-
311
- function __wbg_get_imports() {
312
- const imports = {};
313
- imports.wbg = {};
314
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
315
- takeObject(arg0);
316
- };
317
- imports.wbg.__wbg_log_40476f78048579b6 = function(arg0, arg1) {
318
- console.log(getStringFromWasm0(arg0, arg1));
319
- };
320
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
321
- const ret = getStringFromWasm0(arg0, arg1);
322
- return addHeapObject(ret);
323
- };
324
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
325
- const ret = getObject(arg0);
326
- return addHeapObject(ret);
327
- };
328
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
329
- const obj = takeObject(arg0).original;
330
- if (obj.cnt-- == 1) {
331
- obj.a = 0;
332
- return true;
333
- }
334
- const ret = false;
335
- return ret;
336
- };
337
- imports.wbg.__wbg_listenerid_12315eee21527820 = function(arg0, arg1) {
338
- const ret = getObject(arg1).__yew_listener_id;
339
- getInt32Memory0()[arg0 / 4 + 1] = isLikeNone(ret) ? 0 : ret;
340
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
341
- };
342
- imports.wbg.__wbg_setlistenerid_3183aae8fa5840fb = function(arg0, arg1) {
343
- getObject(arg0).__yew_listener_id = arg1 >>> 0;
344
- };
345
- imports.wbg.__wbg_setsubtreeid_d32e6327eef1f7fc = function(arg0, arg1) {
346
- getObject(arg0).__yew_subtree_id = arg1 >>> 0;
347
- };
348
- imports.wbg.__wbg_subtreeid_e348577f7ef777e3 = function(arg0, arg1) {
349
- const ret = getObject(arg1).__yew_subtree_id;
350
- getInt32Memory0()[arg0 / 4 + 1] = isLikeNone(ret) ? 0 : ret;
351
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
352
- };
353
- imports.wbg.__wbg_cachekey_b61393159c57fd7b = function(arg0, arg1) {
354
- const ret = getObject(arg1).__yew_subtree_cache_key;
355
- getInt32Memory0()[arg0 / 4 + 1] = isLikeNone(ret) ? 0 : ret;
356
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
357
- };
358
- imports.wbg.__wbg_setcachekey_80183b7cfc421143 = function(arg0, arg1) {
359
- getObject(arg0).__yew_subtree_cache_key = arg1 >>> 0;
360
- };
361
- imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
362
- const ret = new Error();
363
- return addHeapObject(ret);
364
- };
365
- imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
366
- const ret = getObject(arg1).stack;
367
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
- const len1 = WASM_VECTOR_LEN;
369
- getInt32Memory0()[arg0 / 4 + 1] = len1;
370
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
371
- };
372
- imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
373
- let deferred0_0;
374
- let deferred0_1;
375
- try {
376
- deferred0_0 = arg0;
377
- deferred0_1 = arg1;
378
- console.error(getStringFromWasm0(arg0, arg1));
379
- } finally {
380
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
381
- }
382
- };
383
- imports.wbg.__wbg_error_71d6845bf00a930f = function(arg0, arg1) {
384
- var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
385
- wasm.__wbindgen_free(arg0, arg1 * 4);
386
- console.error(...v0);
387
- };
388
- imports.wbg.__wbg_warn_0b90a269a514ae1d = function(arg0, arg1) {
389
- var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
390
- wasm.__wbindgen_free(arg0, arg1 * 4);
391
- console.warn(...v0);
392
- };
393
- imports.wbg.__wbg_location_7ac41949b772ef21 = function(arg0) {
394
- const ret = getObject(arg0).location;
395
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
396
- };
397
- imports.wbg.__wbg_body_674aec4c1c0910cd = function(arg0) {
398
- const ret = getObject(arg0).body;
399
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
400
- };
401
- imports.wbg.__wbg_createElement_4891554b28d3388b = function() { return handleError(function (arg0, arg1, arg2) {
402
- const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2));
403
- return addHeapObject(ret);
404
- }, arguments) };
405
- imports.wbg.__wbg_createElementNS_119acf9e82482041 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
406
- const ret = getObject(arg0).createElementNS(arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
407
- return addHeapObject(ret);
408
- }, arguments) };
409
- imports.wbg.__wbg_createTextNode_2fd22cd7e543f938 = function(arg0, arg1, arg2) {
410
- const ret = getObject(arg0).createTextNode(getStringFromWasm0(arg1, arg2));
411
- return addHeapObject(ret);
412
- };
413
- imports.wbg.__wbg_instanceof_Window_9029196b662bc42a = function(arg0) {
414
- let result;
415
- try {
416
- result = getObject(arg0) instanceof Window;
417
- } catch {
418
- result = false;
419
- }
420
- const ret = result;
421
- return ret;
422
- };
423
- imports.wbg.__wbg_document_f7ace2b956f30a4f = function(arg0) {
424
- const ret = getObject(arg0).document;
425
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
426
- };
427
- imports.wbg.__wbg_location_56243dba507f472d = function(arg0) {
428
- const ret = getObject(arg0).location;
429
- return addHeapObject(ret);
430
- };
431
- imports.wbg.__wbg_performance_2c295061c8b01e0b = function(arg0) {
432
- const ret = getObject(arg0).performance;
433
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
434
- };
435
- imports.wbg.__wbg_fetch_336b6f0cb426b46e = function(arg0, arg1) {
436
- const ret = getObject(arg0).fetch(getObject(arg1));
437
- return addHeapObject(ret);
438
- };
439
- imports.wbg.__wbg_setchecked_e5a50baea447b8a8 = function(arg0, arg1) {
440
- getObject(arg0).checked = arg1 !== 0;
441
- };
442
- imports.wbg.__wbg_value_9423da9d988ee8cf = function(arg0, arg1) {
443
- const ret = getObject(arg1).value;
444
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
445
- const len1 = WASM_VECTOR_LEN;
446
- getInt32Memory0()[arg0 / 4 + 1] = len1;
447
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
448
- };
449
- imports.wbg.__wbg_setvalue_1f95e61cbc382f7f = function(arg0, arg1, arg2) {
450
- getObject(arg0).value = getStringFromWasm0(arg1, arg2);
451
- };
452
- imports.wbg.__wbg_newwithstrandinit_cad5cd6038c7ff5d = function() { return handleError(function (arg0, arg1, arg2) {
453
- const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
454
- return addHeapObject(ret);
455
- }, arguments) };
456
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
457
- const obj = getObject(arg1);
458
- const ret = typeof(obj) === 'string' ? obj : undefined;
459
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
460
- var len1 = WASM_VECTOR_LEN;
461
- getInt32Memory0()[arg0 / 4 + 1] = len1;
462
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
463
- };
464
- imports.wbg.__wbg_setonmessage_f0bd0280573b7084 = function(arg0, arg1) {
465
- getObject(arg0).onmessage = getObject(arg1);
466
- };
467
- imports.wbg.__wbg_new_8e7322f46d5d019c = function() { return handleError(function (arg0, arg1) {
468
- const ret = new Worker(getStringFromWasm0(arg0, arg1));
469
- return addHeapObject(ret);
470
- }, arguments) };
471
- imports.wbg.__wbg_newwithoptions_1bd20b45061ed935 = function() { return handleError(function (arg0, arg1, arg2) {
472
- const ret = new Worker(getStringFromWasm0(arg0, arg1), getObject(arg2));
473
- return addHeapObject(ret);
474
- }, arguments) };
475
- imports.wbg.__wbg_postMessage_8c609e2bde333d9c = function() { return handleError(function (arg0, arg1) {
476
- getObject(arg0).postMessage(getObject(arg1));
477
- }, arguments) };
478
- imports.wbg.__wbg_instanceof_Response_fc4327dbfcdf5ced = function(arg0) {
479
- let result;
480
- try {
481
- result = getObject(arg0) instanceof Response;
482
- } catch {
483
- result = false;
484
- }
485
- const ret = result;
486
- return ret;
487
- };
488
- imports.wbg.__wbg_blob_34990e4300d45f53 = function() { return handleError(function (arg0) {
489
- const ret = getObject(arg0).blob();
490
- return addHeapObject(ret);
491
- }, arguments) };
492
- imports.wbg.__wbg_now_0cfdc90c97d0c24b = function(arg0) {
493
- const ret = getObject(arg0).now();
494
- return ret;
495
- };
496
- imports.wbg.__wbg_debug_9b8701f894da9929 = function(arg0, arg1, arg2, arg3) {
497
- console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
498
- };
499
- imports.wbg.__wbg_error_788ae33f81d3b84b = function(arg0) {
500
- console.error(getObject(arg0));
501
- };
502
- imports.wbg.__wbg_error_d9bce418caafb712 = function(arg0, arg1, arg2, arg3) {
503
- console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
504
- };
505
- imports.wbg.__wbg_info_bb52f40b06f679de = function(arg0, arg1, arg2, arg3) {
506
- console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
507
- };
508
- imports.wbg.__wbg_log_ea7093e35e3efd07 = function(arg0, arg1, arg2, arg3) {
509
- console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
510
- };
511
- imports.wbg.__wbg_warn_dfc0e0cf544a13bd = function(arg0, arg1, arg2, arg3) {
512
- console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
513
- };
514
- imports.wbg.__wbg_instanceof_Element_4622f5da1249a3eb = function(arg0) {
515
- let result;
516
- try {
517
- result = getObject(arg0) instanceof Element;
518
- } catch {
519
- result = false;
520
- }
521
- const ret = result;
522
- return ret;
523
- };
524
- imports.wbg.__wbg_namespaceURI_31718ed49b5343a3 = function(arg0, arg1) {
525
- const ret = getObject(arg1).namespaceURI;
526
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
527
- var len1 = WASM_VECTOR_LEN;
528
- getInt32Memory0()[arg0 / 4 + 1] = len1;
529
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
530
- };
531
- imports.wbg.__wbg_setinnerHTML_b089587252408b67 = function(arg0, arg1, arg2) {
532
- getObject(arg0).innerHTML = getStringFromWasm0(arg1, arg2);
533
- };
534
- imports.wbg.__wbg_outerHTML_f7749ceff37b5832 = function(arg0, arg1) {
535
- const ret = getObject(arg1).outerHTML;
536
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
537
- const len1 = WASM_VECTOR_LEN;
538
- getInt32Memory0()[arg0 / 4 + 1] = len1;
539
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
540
- };
541
- imports.wbg.__wbg_children_27ed308801b57d3f = function(arg0) {
542
- const ret = getObject(arg0).children;
543
- return addHeapObject(ret);
544
- };
545
- imports.wbg.__wbg_removeAttribute_d8404da431968808 = function() { return handleError(function (arg0, arg1, arg2) {
546
- getObject(arg0).removeAttribute(getStringFromWasm0(arg1, arg2));
547
- }, arguments) };
548
- imports.wbg.__wbg_setAttribute_e7e80b478b7b8b2f = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
549
- getObject(arg0).setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
550
- }, arguments) };
551
- imports.wbg.__wbg_origin_50aa482fa6784a0a = function() { return handleError(function (arg0, arg1) {
552
- const ret = getObject(arg1).origin;
553
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
554
- const len1 = WASM_VECTOR_LEN;
555
- getInt32Memory0()[arg0 / 4 + 1] = len1;
556
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
557
- }, arguments) };
558
- imports.wbg.__wbg_pathname_c8fd5c498079312d = function() { return handleError(function (arg0, arg1) {
559
- const ret = getObject(arg1).pathname;
560
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
561
- const len1 = WASM_VECTOR_LEN;
562
- getInt32Memory0()[arg0 / 4 + 1] = len1;
563
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
564
- }, arguments) };
565
- imports.wbg.__wbg_data_ab99ae4a2e1e8bc9 = function(arg0) {
566
- const ret = getObject(arg0).data;
567
- return addHeapObject(ret);
568
- };
569
- imports.wbg.__wbg_bubbles_63572b91f3885ef1 = function(arg0) {
570
- const ret = getObject(arg0).bubbles;
571
- return ret;
572
- };
573
- imports.wbg.__wbg_cancelBubble_90d1c3aa2a76cbeb = function(arg0) {
574
- const ret = getObject(arg0).cancelBubble;
575
- return ret;
576
- };
577
- imports.wbg.__wbg_composedPath_cf1bb5b8bcff496f = function(arg0) {
578
- const ret = getObject(arg0).composedPath();
579
- return addHeapObject(ret);
580
- };
581
- imports.wbg.__wbg_parentNode_9e53f8b17eb98c9d = function(arg0) {
582
- const ret = getObject(arg0).parentNode;
583
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
584
- };
585
- imports.wbg.__wbg_parentElement_c75962bc9997ea5f = function(arg0) {
586
- const ret = getObject(arg0).parentElement;
587
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
588
- };
589
- imports.wbg.__wbg_lastChild_0cee692010bac6c2 = function(arg0) {
590
- const ret = getObject(arg0).lastChild;
591
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
592
- };
593
- imports.wbg.__wbg_nextSibling_304d9aac7c2774ae = function(arg0) {
594
- const ret = getObject(arg0).nextSibling;
595
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
596
- };
597
- imports.wbg.__wbg_setnodeValue_d1c8382910b45e04 = function(arg0, arg1, arg2) {
598
- getObject(arg0).nodeValue = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
599
- };
600
- imports.wbg.__wbg_textContent_c5d9e21ee03c63d4 = function(arg0, arg1) {
601
- const ret = getObject(arg1).textContent;
602
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
603
- var len1 = WASM_VECTOR_LEN;
604
- getInt32Memory0()[arg0 / 4 + 1] = len1;
605
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
606
- };
607
- imports.wbg.__wbg_appendChild_51339d4cde00ee22 = function() { return handleError(function (arg0, arg1) {
608
- const ret = getObject(arg0).appendChild(getObject(arg1));
609
- return addHeapObject(ret);
610
- }, arguments) };
611
- imports.wbg.__wbg_insertBefore_ffa01d4b747c95fc = function() { return handleError(function (arg0, arg1, arg2) {
612
- const ret = getObject(arg0).insertBefore(getObject(arg1), getObject(arg2));
613
- return addHeapObject(ret);
614
- }, arguments) };
615
- imports.wbg.__wbg_removeChild_973429f368206138 = function() { return handleError(function (arg0, arg1) {
616
- const ret = getObject(arg0).removeChild(getObject(arg1));
617
- return addHeapObject(ret);
618
- }, arguments) };
619
- imports.wbg.__wbg_createObjectURL_d82f2880bada6a1d = function() { return handleError(function (arg0, arg1) {
620
- const ret = URL.createObjectURL(getObject(arg1));
621
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
622
- const len1 = WASM_VECTOR_LEN;
623
- getInt32Memory0()[arg0 / 4 + 1] = len1;
624
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
625
- }, arguments) };
626
- imports.wbg.__wbg_newwithstrsequenceandoptions_fd88a547f6d15707 = function() { return handleError(function (arg0, arg1) {
627
- const ret = new Blob(getObject(arg0), getObject(arg1));
628
- return addHeapObject(ret);
629
- }, arguments) };
630
- imports.wbg.__wbg_arrayBuffer_27cefaea55cbf063 = function(arg0) {
631
- const ret = getObject(arg0).arrayBuffer();
632
- return addHeapObject(ret);
633
- };
634
- imports.wbg.__wbg_addEventListener_a5963e26cd7b176b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
635
- getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3), getObject(arg4));
636
- }, arguments) };
637
- imports.wbg.__wbg_instanceof_ShadowRoot_b64337370f59fe2d = function(arg0) {
638
- let result;
639
- try {
640
- result = getObject(arg0) instanceof ShadowRoot;
641
- } catch {
642
- result = false;
643
- }
644
- const ret = result;
645
- return ret;
646
- };
647
- imports.wbg.__wbg_host_e1c47c33975060d3 = function(arg0) {
648
- const ret = getObject(arg0).host;
649
- return addHeapObject(ret);
650
- };
651
- imports.wbg.__wbg_value_3c5f08ffc2b7d6f9 = function(arg0, arg1) {
652
- const ret = getObject(arg1).value;
653
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
654
- const len1 = WASM_VECTOR_LEN;
655
- getInt32Memory0()[arg0 / 4 + 1] = len1;
656
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
657
- };
658
- imports.wbg.__wbg_setvalue_0dc100d4b9908028 = function(arg0, arg1, arg2) {
659
- getObject(arg0).value = getStringFromWasm0(arg1, arg2);
660
- };
661
- imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) {
662
- const ret = getObject(arg0)[arg1 >>> 0];
663
- return addHeapObject(ret);
664
- };
665
- imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) {
666
- const ret = getObject(arg0).length;
667
- return ret;
668
- };
669
- imports.wbg.__wbg_new_898a68150f225f2e = function() {
670
- const ret = new Array();
671
- return addHeapObject(ret);
672
- };
673
- imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
674
- const ret = new Function(getStringFromWasm0(arg0, arg1));
675
- return addHeapObject(ret);
676
- };
677
- imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
678
- const ret = getObject(arg0).call(getObject(arg1));
679
- return addHeapObject(ret);
680
- }, arguments) };
681
- imports.wbg.__wbg_new_b51585de1b234aff = function() {
682
- const ret = new Object();
683
- return addHeapObject(ret);
684
- };
685
- imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
686
- const ret = self.self;
687
- return addHeapObject(ret);
688
- }, arguments) };
689
- imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
690
- const ret = window.window;
691
- return addHeapObject(ret);
692
- }, arguments) };
693
- imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
694
- const ret = globalThis.globalThis;
695
- return addHeapObject(ret);
696
- }, arguments) };
697
- imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
698
- const ret = global.global;
699
- return addHeapObject(ret);
700
- }, arguments) };
701
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
702
- const ret = getObject(arg0) === undefined;
703
- return ret;
704
- };
705
- imports.wbg.__wbg_from_d7c216d4616bb368 = function(arg0) {
706
- const ret = Array.from(getObject(arg0));
707
- return addHeapObject(ret);
708
- };
709
- imports.wbg.__wbg_push_ca1c26067ef907ac = function(arg0, arg1) {
710
- const ret = getObject(arg0).push(getObject(arg1));
711
- return ret;
712
- };
713
- imports.wbg.__wbg_new0_c0be7df4b6bd481f = function() {
714
- const ret = new Date();
715
- return addHeapObject(ret);
716
- };
717
- imports.wbg.__wbg_toString_6dc15322a0919dfa = function(arg0) {
718
- const ret = getObject(arg0).toString();
719
- return addHeapObject(ret);
720
- };
721
- imports.wbg.__wbg_is_205d914af04a8faa = function(arg0, arg1) {
722
- const ret = Object.is(getObject(arg0), getObject(arg1));
723
- return ret;
724
- };
725
- imports.wbg.__wbg_resolve_53698b95aaf7fcf8 = function(arg0) {
726
- const ret = Promise.resolve(getObject(arg0));
727
- return addHeapObject(ret);
728
- };
729
- imports.wbg.__wbg_then_f7e06ee3c11698eb = function(arg0, arg1) {
730
- const ret = getObject(arg0).then(getObject(arg1));
731
- return addHeapObject(ret);
732
- };
733
- imports.wbg.__wbg_then_b2267541e2a73865 = function(arg0, arg1, arg2) {
734
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
735
- return addHeapObject(ret);
736
- };
737
- imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
738
- const ret = getObject(arg0).buffer;
739
- return addHeapObject(ret);
740
- };
741
- imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
742
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
743
- return addHeapObject(ret);
744
- };
745
- imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
746
- const ret = new Uint8Array(getObject(arg0));
747
- return addHeapObject(ret);
748
- };
749
- imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
750
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
751
- };
752
- imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
753
- const ret = getObject(arg0).length;
754
- return ret;
755
- };
756
- imports.wbg.__wbg_set_092e06b0f9d71865 = function() { return handleError(function (arg0, arg1, arg2) {
757
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
758
- return ret;
759
- }, arguments) };
760
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
761
- const ret = debugString(getObject(arg1));
762
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
763
- const len1 = WASM_VECTOR_LEN;
764
- getInt32Memory0()[arg0 / 4 + 1] = len1;
765
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
766
- };
767
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
768
- throw new Error(getStringFromWasm0(arg0, arg1));
769
- };
770
- imports.wbg.__wbindgen_memory = function() {
771
- const ret = wasm.memory;
772
- return addHeapObject(ret);
773
- };
774
- imports.wbg.__wbindgen_closure_wrapper203 = function(arg0, arg1, arg2) {
775
- const ret = makeClosure(arg0, arg1, 55, __wbg_adapter_20);
776
- return addHeapObject(ret);
777
- };
778
- imports.wbg.__wbindgen_closure_wrapper399 = function(arg0, arg1, arg2) {
779
- const ret = makeMutClosure(arg0, arg1, 128, __wbg_adapter_23);
780
- return addHeapObject(ret);
781
- };
782
- imports.wbg.__wbindgen_closure_wrapper694 = function(arg0, arg1, arg2) {
783
- const ret = makeMutClosure(arg0, arg1, 245, __wbg_adapter_26);
784
- return addHeapObject(ret);
785
- };
786
-
787
- return imports;
788
- }
789
-
790
- function __wbg_init_memory(imports, maybe_memory) {
791
-
792
- }
793
-
794
- function __wbg_finalize_init(instance, module) {
795
- wasm = instance.exports;
796
- __wbg_init.__wbindgen_wasm_module = module;
797
- cachedInt32Memory0 = null;
798
- cachedUint32Memory0 = null;
799
- cachedUint8Memory0 = null;
800
-
801
- wasm.__wbindgen_start();
802
- return wasm;
803
- }
804
-
805
- function initSync(module) {
806
- if (wasm !== undefined) return wasm;
807
-
808
- const imports = __wbg_get_imports();
809
-
810
- __wbg_init_memory(imports);
811
-
812
- if (!(module instanceof WebAssembly.Module)) {
813
- module = new WebAssembly.Module(module);
814
- }
815
-
816
- const instance = new WebAssembly.Instance(module, imports);
817
-
818
- return __wbg_finalize_init(instance, module);
819
- }
820
-
821
- async function __wbg_init(input) {
822
- if (wasm !== undefined) return wasm;
823
-
824
- if (typeof input === 'undefined') {
825
- input = new URL('app-5d6e90e818ed37ea_bg.wasm', import.meta.url);
826
- }
827
- const imports = __wbg_get_imports();
828
-
829
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
830
- input = fetch(input);
831
- }
832
-
833
- __wbg_init_memory(imports);
834
-
835
- const { instance, module } = await __wbg_load(await input, imports);
836
-
837
- return __wbg_finalize_init(instance, module);
838
- }
839
-
840
- export { initSync }
841
- export default __wbg_init;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app-5d6e90e818ed37ea_bg.wasm DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5284e85578338566cf7b434e0f0da9ac9926e85dcf125d5afbaa0bba6ee5a2b5
3
- size 295553
 
 
 
 
build/m.d.ts ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ */
5
+ export class Decoder {
6
+ free(): void;
7
+ /**
8
+ * @param {Uint8Array} weights
9
+ * @param {Uint8Array} tokenizer
10
+ * @param {Uint8Array} mel_filters
11
+ */
12
+ constructor(weights: Uint8Array, tokenizer: Uint8Array, mel_filters: Uint8Array);
13
+ /**
14
+ * @param {Uint8Array} wav_input
15
+ * @returns {string}
16
+ */
17
+ decode(wav_input: Uint8Array): string;
18
+ }
19
+
20
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
21
+
22
+ export interface InitOutput {
23
+ readonly memory: WebAssembly.Memory;
24
+ readonly __wbg_decoder_free: (a: number) => void;
25
+ readonly decoder_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
26
+ readonly decoder_decode: (a: number, b: number, c: number, d: number) => void;
27
+ readonly main: (a: number, b: number) => number;
28
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
29
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
30
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
31
+ readonly __wbindgen_start: () => void;
32
+ }
33
+
34
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
35
+ /**
36
+ * Instantiates the given `module`, which can either be bytes or
37
+ * a precompiled `WebAssembly.Module`.
38
+ *
39
+ * @param {SyncInitInput} module
40
+ *
41
+ * @returns {InitOutput}
42
+ */
43
+ export function initSync(module: SyncInitInput): InitOutput;
44
+
45
+ /**
46
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
47
+ * for everything else, calls `WebAssembly.instantiate` directly.
48
+ *
49
+ * @param {InitInput | Promise<InitInput>} module_or_path
50
+ *
51
+ * @returns {Promise<InitOutput>}
52
+ */
53
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
worker.js β†’ build/m.js RENAMED
@@ -1,107 +1,8 @@
1
- let wasm_bindgen;
2
- (function() {
3
- const __exports = {};
4
- let script_src;
5
- if (typeof document !== 'undefined' && document.currentScript !== null) {
6
- script_src = new URL(document.currentScript.src, location.href).toString();
7
- }
8
- let wasm = undefined;
9
-
10
- const heap = new Array(128).fill(undefined);
11
-
12
- heap.push(undefined, null, true, false);
13
-
14
- function getObject(idx) { return heap[idx]; }
15
-
16
- let heap_next = heap.length;
17
-
18
- function dropObject(idx) {
19
- if (idx < 132) return;
20
- heap[idx] = heap_next;
21
- heap_next = idx;
22
- }
23
-
24
- function takeObject(idx) {
25
- const ret = getObject(idx);
26
- dropObject(idx);
27
- return ret;
28
- }
29
 
30
- function addHeapObject(obj) {
31
- if (heap_next === heap.length) heap.push(heap.length + 1);
32
- const idx = heap_next;
33
- heap_next = heap[idx];
34
-
35
- heap[idx] = obj;
36
- return idx;
37
- }
38
-
39
- function debugString(val) {
40
- // primitive types
41
- const type = typeof val;
42
- if (type == 'number' || type == 'boolean' || val == null) {
43
- return `${val}`;
44
- }
45
- if (type == 'string') {
46
- return `"${val}"`;
47
- }
48
- if (type == 'symbol') {
49
- const description = val.description;
50
- if (description == null) {
51
- return 'Symbol';
52
- } else {
53
- return `Symbol(${description})`;
54
- }
55
- }
56
- if (type == 'function') {
57
- const name = val.name;
58
- if (typeof name == 'string' && name.length > 0) {
59
- return `Function(${name})`;
60
- } else {
61
- return 'Function';
62
- }
63
- }
64
- // objects
65
- if (Array.isArray(val)) {
66
- const length = val.length;
67
- let debug = '[';
68
- if (length > 0) {
69
- debug += debugString(val[0]);
70
- }
71
- for(let i = 1; i < length; i++) {
72
- debug += ', ' + debugString(val[i]);
73
- }
74
- debug += ']';
75
- return debug;
76
- }
77
- // Test for built-in
78
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
79
- let className;
80
- if (builtInMatches.length > 1) {
81
- className = builtInMatches[1];
82
- } else {
83
- // Failed to match the standard '[object ClassName]'
84
- return toString.call(val);
85
- }
86
- if (className == 'Object') {
87
- // we're a user defined class or Object
88
- // JSON.stringify avoids problems with cycles, and is generally much
89
- // easier than looping through ownProperties of `val`.
90
- try {
91
- return 'Object(' + JSON.stringify(val) + ')';
92
- } catch (_) {
93
- return 'Object';
94
- }
95
- }
96
- // errors
97
- if (val instanceof Error) {
98
- return `${val.name}: ${val.message}\n${val.stack}`;
99
- }
100
- // TODO we could test for more things here, like `Set`s and `Map`s.
101
- return className;
102
- }
103
 
104
- let WASM_VECTOR_LEN = 0;
105
 
106
  let cachedUint8Memory0 = null;
107
 
@@ -112,56 +13,32 @@ function getUint8Memory0() {
112
  return cachedUint8Memory0;
113
  }
114
 
115
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
116
-
117
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
118
- ? function (arg, view) {
119
- return cachedTextEncoder.encodeInto(arg, view);
120
  }
121
- : function (arg, view) {
122
- const buf = cachedTextEncoder.encode(arg);
123
- view.set(buf);
124
- return {
125
- read: arg.length,
126
- written: buf.length
127
- };
128
- });
129
-
130
- function passStringToWasm0(arg, malloc, realloc) {
131
 
132
- if (realloc === undefined) {
133
- const buf = cachedTextEncoder.encode(arg);
134
- const ptr = malloc(buf.length, 1) >>> 0;
135
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
136
- WASM_VECTOR_LEN = buf.length;
137
- return ptr;
138
- }
139
 
140
- let len = arg.length;
141
- let ptr = malloc(len, 1) >>> 0;
142
 
143
- const mem = getUint8Memory0();
144
-
145
- let offset = 0;
146
 
147
- for (; offset < len; offset++) {
148
- const code = arg.charCodeAt(offset);
149
- if (code > 0x7F) break;
150
- mem[ptr + offset] = code;
151
- }
152
 
153
- if (offset !== len) {
154
- if (offset !== 0) {
155
- arg = arg.slice(offset);
156
- }
157
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
158
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
159
- const ret = encodeString(arg, view);
160
 
161
- offset += ret.written;
162
- }
163
 
164
- WASM_VECTOR_LEN = offset;
 
 
 
165
  return ptr;
166
  }
167
 
@@ -174,45 +51,97 @@ function getInt32Memory0() {
174
  return cachedInt32Memory0;
175
  }
176
 
177
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
178
 
179
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
 
 
 
 
180
 
181
- function getStringFromWasm0(ptr, len) {
182
- ptr = ptr >>> 0;
183
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
 
184
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
- function makeClosure(arg0, arg1, dtor, f) {
187
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
188
- const real = (...args) => {
189
- // First up with a closure we increment the internal reference
190
- // count. This ensures that the Rust closure environment won't
191
- // be deallocated while we're invoking it.
192
- state.cnt++;
 
 
 
193
  try {
194
- return f(state.a, state.b, ...args);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  } finally {
196
- if (--state.cnt === 0) {
197
- wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b);
198
- state.a = 0;
199
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
 
 
 
 
 
 
201
  }
202
- };
203
- real.original = state;
204
-
205
- return real;
206
- }
207
- function __wbg_adapter_14(arg0, arg1, arg2) {
208
- wasm._dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he08b923c8dd4296d(arg0, arg1, addHeapObject(arg2));
209
- }
210
-
211
- function handleError(f, args) {
212
- try {
213
- return f.apply(this, args);
214
- } catch (e) {
215
- wasm.__wbindgen_exn_store(addHeapObject(e));
216
  }
217
  }
218
 
@@ -250,100 +179,22 @@ async function __wbg_load(module, imports) {
250
  function __wbg_get_imports() {
251
  const imports = {};
252
  imports.wbg = {};
253
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
254
- takeObject(arg0);
255
- };
256
- imports.wbg.__wbg_log_40476f78048579b6 = function(arg0, arg1) {
257
- console.log(getStringFromWasm0(arg0, arg1));
258
- };
259
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
260
- const ret = getObject(arg0);
261
  return addHeapObject(ret);
262
  };
263
- imports.wbg.__wbg_setonmessage_731266b6f3ab0860 = function(arg0, arg1) {
264
- getObject(arg0).onmessage = getObject(arg1);
265
- };
266
- imports.wbg.__wbg_close_889c0c4e86f1403e = function(arg0) {
267
- getObject(arg0).close();
268
  };
269
- imports.wbg.__wbg_postMessage_2f0b8369b84c3c1e = function() { return handleError(function (arg0, arg1) {
270
- getObject(arg0).postMessage(getObject(arg1));
271
- }, arguments) };
272
  imports.wbg.__wbg_time_fa135a7c2786e907 = function(arg0, arg1) {
273
  console.time(getStringFromWasm0(arg0, arg1));
274
  };
275
  imports.wbg.__wbg_timeEnd_594d82f147c9776f = function(arg0, arg1) {
276
  console.timeEnd(getStringFromWasm0(arg0, arg1));
277
  };
278
- imports.wbg.__wbg_data_ab99ae4a2e1e8bc9 = function(arg0) {
279
- const ret = getObject(arg0).data;
280
- return addHeapObject(ret);
281
- };
282
- imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
283
- const ret = new Function(getStringFromWasm0(arg0, arg1));
284
- return addHeapObject(ret);
285
- };
286
- imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
287
- const ret = getObject(arg0).call(getObject(arg1));
288
- return addHeapObject(ret);
289
- }, arguments) };
290
- imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
291
- const ret = self.self;
292
- return addHeapObject(ret);
293
- }, arguments) };
294
- imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
295
- const ret = window.window;
296
- return addHeapObject(ret);
297
- }, arguments) };
298
- imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
299
- const ret = globalThis.globalThis;
300
- return addHeapObject(ret);
301
- }, arguments) };
302
- imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
303
- const ret = global.global;
304
- return addHeapObject(ret);
305
- }, arguments) };
306
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
307
- const ret = getObject(arg0) === undefined;
308
- return ret;
309
- };
310
- imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
311
- const ret = getObject(arg0).buffer;
312
- return addHeapObject(ret);
313
- };
314
- imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
315
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
316
- return addHeapObject(ret);
317
- };
318
- imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
319
- const ret = new Uint8Array(getObject(arg0));
320
- return addHeapObject(ret);
321
- };
322
- imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
323
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
324
- };
325
- imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
326
- const ret = getObject(arg0).length;
327
- return ret;
328
- };
329
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
330
- const ret = debugString(getObject(arg1));
331
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
- const len1 = WASM_VECTOR_LEN;
333
- getInt32Memory0()[arg0 / 4 + 1] = len1;
334
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
335
- };
336
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
337
  throw new Error(getStringFromWasm0(arg0, arg1));
338
  };
339
- imports.wbg.__wbindgen_memory = function() {
340
- const ret = wasm.memory;
341
- return addHeapObject(ret);
342
- };
343
- imports.wbg.__wbindgen_closure_wrapper63 = function(arg0, arg1, arg2) {
344
- const ret = makeClosure(arg0, arg1, 18, __wbg_adapter_14);
345
- return addHeapObject(ret);
346
- };
347
 
348
  return imports;
349
  }
@@ -381,8 +232,8 @@ function initSync(module) {
381
  async function __wbg_init(input) {
382
  if (wasm !== undefined) return wasm;
383
 
384
- if (typeof input === 'undefined' && script_src !== 'undefined') {
385
- input = script_src.replace(/\.js$/, '_bg.wasm');
386
  }
387
  const imports = __wbg_get_imports();
388
 
@@ -397,6 +248,5 @@ async function __wbg_init(input) {
397
  return __wbg_finalize_init(instance, module);
398
  }
399
 
400
- wasm_bindgen = Object.assign(__wbg_init, { initSync }, __exports);
401
-
402
- })();
 
1
+ let wasm;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
6
 
7
  let cachedUint8Memory0 = null;
8
 
 
13
  return cachedUint8Memory0;
14
  }
15
 
16
+ function getStringFromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
 
 
19
  }
 
 
 
 
 
 
 
 
 
 
20
 
21
+ const heap = new Array(128).fill(undefined);
 
 
 
 
 
 
22
 
23
+ heap.push(undefined, null, true, false);
 
24
 
25
+ let heap_next = heap.length;
 
 
26
 
27
+ function addHeapObject(obj) {
28
+ if (heap_next === heap.length) heap.push(heap.length + 1);
29
+ const idx = heap_next;
30
+ heap_next = heap[idx];
 
31
 
32
+ heap[idx] = obj;
33
+ return idx;
34
+ }
 
 
 
 
35
 
36
+ let WASM_VECTOR_LEN = 0;
 
37
 
38
+ function passArray8ToWasm0(arg, malloc) {
39
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
40
+ getUint8Memory0().set(arg, ptr / 1);
41
+ WASM_VECTOR_LEN = arg.length;
42
  return ptr;
43
  }
44
 
 
51
  return cachedInt32Memory0;
52
  }
53
 
54
+ function getObject(idx) { return heap[idx]; }
55
 
56
+ function dropObject(idx) {
57
+ if (idx < 132) return;
58
+ heap[idx] = heap_next;
59
+ heap_next = idx;
60
+ }
61
 
62
+ function takeObject(idx) {
63
+ const ret = getObject(idx);
64
+ dropObject(idx);
65
+ return ret;
66
  }
67
+ /**
68
+ */
69
+ export class Decoder {
70
+
71
+ static __wrap(ptr) {
72
+ ptr = ptr >>> 0;
73
+ const obj = Object.create(Decoder.prototype);
74
+ obj.__wbg_ptr = ptr;
75
+
76
+ return obj;
77
+ }
78
+
79
+ __destroy_into_raw() {
80
+ const ptr = this.__wbg_ptr;
81
+ this.__wbg_ptr = 0;
82
+
83
+ return ptr;
84
+ }
85
 
86
+ free() {
87
+ const ptr = this.__destroy_into_raw();
88
+ wasm.__wbg_decoder_free(ptr);
89
+ }
90
+ /**
91
+ * @param {Uint8Array} weights
92
+ * @param {Uint8Array} tokenizer
93
+ * @param {Uint8Array} mel_filters
94
+ */
95
+ constructor(weights, tokenizer, mel_filters) {
96
  try {
97
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
98
+ const ptr0 = passArray8ToWasm0(weights, wasm.__wbindgen_malloc);
99
+ const len0 = WASM_VECTOR_LEN;
100
+ const ptr1 = passArray8ToWasm0(tokenizer, wasm.__wbindgen_malloc);
101
+ const len1 = WASM_VECTOR_LEN;
102
+ const ptr2 = passArray8ToWasm0(mel_filters, wasm.__wbindgen_malloc);
103
+ const len2 = WASM_VECTOR_LEN;
104
+ wasm.decoder_new(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
105
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
106
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
107
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
108
+ if (r2) {
109
+ throw takeObject(r1);
110
+ }
111
+ return Decoder.__wrap(r0);
112
  } finally {
113
+ wasm.__wbindgen_add_to_stack_pointer(16);
114
+ }
115
+ }
116
+ /**
117
+ * @param {Uint8Array} wav_input
118
+ * @returns {string}
119
+ */
120
+ decode(wav_input) {
121
+ let deferred3_0;
122
+ let deferred3_1;
123
+ try {
124
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
125
+ const ptr0 = passArray8ToWasm0(wav_input, wasm.__wbindgen_malloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ wasm.decoder_decode(retptr, this.__wbg_ptr, ptr0, len0);
128
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
129
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
130
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
131
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
132
+ var ptr2 = r0;
133
+ var len2 = r1;
134
+ if (r3) {
135
+ ptr2 = 0; len2 = 0;
136
+ throw takeObject(r2);
137
  }
138
+ deferred3_0 = ptr2;
139
+ deferred3_1 = len2;
140
+ return getStringFromWasm0(ptr2, len2);
141
+ } finally {
142
+ wasm.__wbindgen_add_to_stack_pointer(16);
143
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
  }
147
 
 
179
  function __wbg_get_imports() {
180
  const imports = {};
181
  imports.wbg = {};
182
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
183
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
 
 
 
 
 
 
184
  return addHeapObject(ret);
185
  };
186
+ imports.wbg.__wbg_log_f448472545eafac4 = function(arg0, arg1) {
187
+ console.log(getStringFromWasm0(arg0, arg1));
 
 
 
188
  };
 
 
 
189
  imports.wbg.__wbg_time_fa135a7c2786e907 = function(arg0, arg1) {
190
  console.time(getStringFromWasm0(arg0, arg1));
191
  };
192
  imports.wbg.__wbg_timeEnd_594d82f147c9776f = function(arg0, arg1) {
193
  console.timeEnd(getStringFromWasm0(arg0, arg1));
194
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
196
  throw new Error(getStringFromWasm0(arg0, arg1));
197
  };
 
 
 
 
 
 
 
 
198
 
199
  return imports;
200
  }
 
232
  async function __wbg_init(input) {
233
  if (wasm !== undefined) return wasm;
234
 
235
+ if (typeof input === 'undefined') {
236
+ input = new URL('m_bg.wasm', import.meta.url);
237
  }
238
  const imports = __wbg_get_imports();
239
 
 
248
  return __wbg_finalize_init(instance, module);
249
  }
250
 
251
+ export { initSync }
252
+ export default __wbg_init;
 
worker_bg.wasm β†’ build/m_bg.wasm RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4bcdd2ec82ec70317632cec7ece70e0c56322515d98c41cf166d61b5d1823633
3
- size 2538005
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa61030475868a6533b28628cd20d4d49c7a00f0e2a044c1f141a3d80f3d8a72
3
+ size 3659953
build/m_bg.wasm.d.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function __wbg_decoder_free(a: number): void;
5
+ export function decoder_new(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
6
+ export function decoder_decode(a: number, b: number, c: number, d: number): void;
7
+ export function main(a: number, b: number): number;
8
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
9
+ export function __wbindgen_malloc(a: number, b: number): number;
10
+ export function __wbindgen_free(a: number, b: number, c: number): void;
11
+ export function __wbindgen_start(): void;
index.html CHANGED
@@ -1,52 +1,313 @@
1
- <!DOCTYPE html><html lang="en"><head>
2
- <meta charset="utf-8">
3
- <title>Welcome to Candle!</title>
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
- <script type="module">import init from '/app-5d6e90e818ed37ea.js';init('/app-5d6e90e818ed37ea_bg.wasm');</script>
15
-
16
-
17
- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
18
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
19
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css">
20
-
21
- <link rel="preload" href="/app-5d6e90e818ed37ea_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
22
- <link rel="modulepreload" href="/app-5d6e90e818ed37ea.js"></head>
23
- <body>
24
-
25
- <script>(function () {
26
- var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
27
- var url = protocol + '//' + window.location.host + '/_trunk/ws';
28
- var poll_interval = 5000;
29
- var reload_upon_connect = () => {
30
- window.setTimeout(
31
- () => {
32
- // when we successfully reconnect, we'll force a
33
- // reload (since we presumably lost connection to
34
- // trunk due to it being killed, so it will have
35
- // rebuilt on restart)
36
- var ws = new WebSocket(url);
37
- ws.onopen = () => window.location.reload();
38
- ws.onclose = reload_upon_connect;
39
- },
40
- poll_interval);
41
- };
42
-
43
- var ws = new WebSocket(url);
44
- ws.onmessage = (ev) => {
45
- const msg = JSON.parse(ev.data);
46
- if (msg.reload) {
47
- window.location.reload();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
- };
50
- ws.onclose = reload_upon_connect;
51
- })()
52
- </script></body></html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
4
+ <title>Candle Whisper Rust/WASM</title>
5
+ </head>
6
+ <body></body>
7
+ </html>
8
+
9
+ <!doctype html>
10
+ <html>
11
+ <head>
12
+ <meta charset="UTF-8" />
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14
+ <style>
15
+ @import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400&family=Source+Sans+3:wght@100;200;300;400;500;600;700;800;900&display=swap");
16
+ html,
17
+ body {
18
+ font-family: "Source Sans 3", sans-serif;
19
+ }
20
+ </style>
21
+ <script src="https://cdn.tailwindcss.com"></script>
22
+ <script type="module">
23
+ // base url for audio examples
24
+ const AUDIO_BASE_URL =
25
+ "https://huggingface.co/datasets/Narsil/candle-examples/resolve/main/";
26
+
27
+ // models base url
28
+ const MODELS = {
29
+ tiny_en: {
30
+ base_url:
31
+ "https://huggingface.co/openai/whisper-tiny.en/resolve/refs%2Fpr%2F17/",
32
+ },
33
+ };
34
+ const whisperWorker = new Worker("./whisperWorker.js", {
35
+ type: "module",
36
+ });
37
+
38
+ async function classifyAudio(
39
+ weightsURL, // URL to the weights file
40
+ modelID, // model ID
41
+ tokenizerURL, // URL to the tokenizer file
42
+ mel_filtersURL, // URL to the mel filters file
43
+ audioURL, // URL to the audio file
44
+ updateStatus // function to update the status
45
+ ) {
46
+ return new Promise((resolve, reject) => {
47
+ whisperWorker.postMessage({
48
+ weightsURL,
49
+ modelID,
50
+ tokenizerURL,
51
+ mel_filtersURL,
52
+ audioURL,
53
+ });
54
+ whisperWorker.addEventListener("message", (event) => {
55
+ console.log(event.data);
56
+ if ("status" in event.data) {
57
+ updateStatus(event.data);
58
+ }
59
+ if ("error" in event.data) {
60
+ reject(new Error(event.data.error));
61
+ }
62
+ if (event.data.status === "complete") {
63
+ resolve(event.data);
64
+ }
65
+ });
66
+ });
67
+ }
68
+
69
+ // keep track of the audio URL
70
+ let audioURL = null;
71
+ function setAudio(src) {
72
+ const audio = document.querySelector("#audio");
73
+ audio.src = src;
74
+ audio.controls = true;
75
+ audio.hidden = false;
76
+ document.querySelector("#detect").disabled = false;
77
+ audioURL = src;
78
+ }
79
+ // add event listener to audio buttons
80
+ document.querySelectorAll("#audios-select > button").forEach((target) => {
81
+ target.addEventListener("click", (e) => {
82
+ const value = target.dataset.value;
83
+ const href = AUDIO_BASE_URL + value;
84
+ setAudio(href);
85
+ });
86
+ });
87
+ //add event listener to file input
88
+ document.querySelector("#file-upload").addEventListener("change", (e) => {
89
+ const target = e.target;
90
+ if (target.files.length > 0) {
91
+ const href = URL.createObjectURL(target.files[0]);
92
+ setAudio(href);
93
+ }
94
+ });
95
+ // add event listener to drop-area
96
+ const dropArea = document.querySelector("#drop-area");
97
+ dropArea.addEventListener("dragenter", (e) => {
98
+ e.preventDefault();
99
+ dropArea.classList.add("border-blue-700");
100
+ });
101
+ dropArea.addEventListener("dragleave", (e) => {
102
+ e.preventDefault();
103
+ dropArea.classList.remove("border-blue-700");
104
+ });
105
+ dropArea.addEventListener("dragover", (e) => {
106
+ e.preventDefault();
107
+ dropArea.classList.add("border-blue-700");
108
+ });
109
+ dropArea.addEventListener("drop", (e) => {
110
+ e.preventDefault();
111
+ dropArea.classList.remove("border-blue-700");
112
+ const url = e.dataTransfer.getData("text/uri-list");
113
+ const files = e.dataTransfer.files;
114
+ if (files.length > 0) {
115
+ const href = URL.createObjectURL(files[0]);
116
+ setAudio(href);
117
+ } else if (url) {
118
+ setAudio(url);
119
+ }
120
+ });
121
+
122
+ // add event listener to detect button
123
+ document.querySelector("#detect").addEventListener("click", async () => {
124
+ if (audioURL === null) {
125
+ return;
126
  }
127
+ const modelID = document.querySelector("#model").value;
128
+ const modelURL = MODELS[modelID].base_url + "model.safetensors";
129
+ const tokenizerURL = MODELS[modelID].base_url + "tokenizer.json";
130
+
131
+ classifyAudio(
132
+ modelURL,
133
+ modelID,
134
+ tokenizerURL,
135
+ "mel_filters.safetensors",
136
+ audioURL,
137
+ updateStatus
138
+ )
139
+ .then((result) => {
140
+ console.log("RESULT", result);
141
+ const { output } = result;
142
+ const text = output.map((segment) => segment.dr.text).join(" ");
143
+ console.log(text);
144
+ document.getElementById("output").textContent = text;
145
+ })
146
+ .catch((error) => {
147
+ console.error(error);
148
+ });
149
+ });
150
+
151
+ function updateStatus(data) {
152
+ const { status, message } = data;
153
+ const button = document.querySelector("#detect");
154
+ if (status === "decoding" || status === "loading") {
155
+ button.disabled = true;
156
+ button.textContent = message;
157
+ } else if (status === "complete") {
158
+ button.disabled = false;
159
+ button.textContent = "Transcribe Audio";
160
+ }
161
+ }
162
+ </script>
163
+ </head>
164
+ <body class="container max-w-4xl mx-auto p-4">
165
+ <main class="grid grid-cols-1 gap-8 relative">
166
+ <span class="absolute text-5xl -ml-[1em]"> πŸ•―οΈ </span>
167
+ <div>
168
+ <h1 class="text-5xl font-bold">Candle Whisper</h1>
169
+ <h2 class="text-2xl font-bold">Rust/WASM Demo</h2>
170
+ <p class="max-w-lg">
171
+ Transcribe audio in the browser using rust/wasm with an audio file.
172
+ This demo uses the
173
+ <a
174
+ href="https://huggingface.co/openai/"
175
+ target="_blank"
176
+ class="underline hover:text-blue-500 hover:no-underline"
177
+ >
178
+ OpenAI Whisper models
179
+ </a>
180
+ and WASM runtime built with
181
+ <a
182
+ href="https://github.com/huggingface/candle/"
183
+ target="_blank"
184
+ class="underline hover:text-blue-500 hover:no-underline"
185
+ >Candle
186
+ </a>
187
+ </p>
188
+ </div>
189
+
190
+ <div>
191
+ <label for="model" class="font-medium">Models Options: </label>
192
+ <select
193
+ id="model"
194
+ class="border-2 border-gray-500 rounded-md font-light"
195
+ >
196
+ <option value="tiny_en" selected>tiny.en (151 MB)</option>
197
+ </select>
198
+ </div>
199
+ <!-- drag and drop area -->
200
+ <div class="relative">
201
+ <div
202
+ id="drop-area"
203
+ class="flex flex-col items-center justify-center border-2 border-gray-300 border-dashed rounded-xl relative h-48 w-full overflow-hidden"
204
+ >
205
+ <div
206
+ class="flex flex-col items-center justify-center space-y-1 text-center"
207
+ >
208
+ <svg
209
+ width="25"
210
+ height="25"
211
+ viewBox="0 0 25 25"
212
+ fill="none"
213
+ xmlns="http://www.w3.org/2000/svg"
214
+ >
215
+ <path
216
+ d="M3.5 24.3a3 3 0 0 1-1.9-.8c-.5-.5-.8-1.2-.8-1.9V2.9c0-.7.3-1.3.8-1.9.6-.5 1.2-.7 2-.7h18.6c.7 0 1.3.2 1.9.7.5.6.7 1.2.7 2v18.6c0 .7-.2 1.4-.7 1.9a3 3 0 0 1-2 .8H3.6Zm0-2.7h18.7V2.9H3.5v18.7Zm2.7-2.7h13.3c.3 0 .5 0 .6-.3v-.7l-3.7-5a.6.6 0 0 0-.6-.2c-.2 0-.4 0-.5.3l-3.5 4.6-2.4-3.3a.6.6 0 0 0-.6-.3c-.2 0-.4.1-.5.3l-2.7 3.6c-.1.2-.2.4 0 .7.1.2.3.3.6.3Z"
217
+ fill="#000"
218
+ />
219
+ </svg>
220
+ <div class="flex text-sm text-gray-600">
221
+ <label
222
+ for="file-upload"
223
+ class="relative cursor-pointer bg-white rounded-md font-medium text-blue-950 hover:text-blue-700"
224
+ >
225
+ <span>Drag and drop your audio here</span>
226
+ <span class="block text-xs">or</span>
227
+ <span class="block text-xs">Click to upload</span>
228
+ </label>
229
+ </div>
230
+ <input
231
+ id="file-upload"
232
+ name="file-upload"
233
+ type="file"
234
+ accept="audio/*"
235
+ class="sr-only"
236
+ />
237
+ </div>
238
+ <audio
239
+ id="audio"
240
+ hidden
241
+ controls
242
+ class="w-full p-2 select-none"
243
+ ></audio>
244
+ </div>
245
+ </div>
246
+ <div>
247
+ <div class="flex flex-wrap gap-3 items-center" id="audios-select">
248
+ <h3 class="font-medium">Examples:</h3>
249
+ <button
250
+ data-value="samples_jfk.wav"
251
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
252
+ >
253
+ <span>jfk.wav</span>
254
+ <span class="text-xs block"> (352 kB)</span>
255
+ </button>
256
+ <button
257
+ data-value="samples_a13.wav"
258
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
259
+ >
260
+ <span>a13.wav</span>
261
+ <span class="text-xs block"> (960 kB)</span>
262
+ </button>
263
+ <button
264
+ data-value="samples_mm0.wav"
265
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
266
+ >
267
+ <span>mm0.wav</span>
268
+ <span class="text-xs block new"> (957 kB)</span>
269
+ </button>
270
+ <button
271
+ data-value="samples_gb0.wav"
272
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
273
+ >
274
+ <span>gb0.wav </span>
275
+ <span class="text-xs block">(4.08 MB)</span>
276
+ </button>
277
+ <button
278
+ data-value="samples_gb1.wav"
279
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
280
+ >
281
+ <span>gb1.wav </span>
282
+ <span class="text-xs block">(6.36 MB)</span>
283
+ </button>
284
+ <button
285
+ data-value="samples_hp0.wav"
286
+ class="text-gray-500 border border-gray-500 rounded-md p-2 underline hover:no-underline"
287
+ >
288
+ <span>hp0.wav </span>
289
+ <span class="text-xs block">(8.75 MB)</span>
290
+ </button>
291
+ </div>
292
+ </div>
293
+
294
+ <div>
295
+ <button
296
+ id="detect"
297
+ disabled
298
+ class="bg-orange-900 hover:bg-orange-800 text-white font-normal py-2 px-4 rounded disabled:opacity-75 disabled:cursor-not-allowed"
299
+ >
300
+ Transcribe Audio
301
+ </button>
302
+ </div>
303
+ <div>
304
+ <h3 class="font-medium">Transcription:</h3>
305
+
306
+ <div
307
+ id="output"
308
+ class="min-h-[100px] bg-slate-500 text-white p-4 rounded-md"
309
+ ></div>
310
+ </div>
311
+ </main>
312
+ </body>
313
+ </html>
style.css DELETED
@@ -1,28 +0,0 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
-
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
- }
10
-
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
- }
17
-
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
- }
25
-
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
whisperWorker.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //load the candle Whisper decoder wasm module
2
+ import init, { Decoder } from "./build/m.js";
3
+
4
+ async function fetchArrayBuffer(url) {
5
+ const res = await fetch(url, {
6
+ cache: "force-cache",
7
+ headers: {
8
+ "Cache-Control": "public, max-age=31536000",
9
+ },
10
+ });
11
+ const data = await res.arrayBuffer();
12
+ return new Uint8Array(data);
13
+ }
14
+
15
+ class Whisper {
16
+ static instance = {};
17
+ // Retrieve the Whisper model. When called for the first time,
18
+ // this will load the model and save it for future use.
19
+ static async getInstance(weightsURL, modelID, tokenizerURL, mel_filtersURL) {
20
+ // load individual modelID only once
21
+ if (!this.instance[modelID]) {
22
+ await init();
23
+
24
+ self.postMessage({ status: "loading", message: "Loading Model" });
25
+ const [weightsArrayU8, tokenizerArrayU8, mel_filtersArrayU8] =
26
+ await Promise.all([
27
+ fetchArrayBuffer(weightsURL),
28
+ fetchArrayBuffer(tokenizerURL),
29
+ fetchArrayBuffer(mel_filtersURL),
30
+ ]);
31
+
32
+ this.instance[modelID] = new Decoder(
33
+ weightsArrayU8,
34
+ tokenizerArrayU8,
35
+ mel_filtersArrayU8
36
+ );
37
+ } else {
38
+ self.postMessage({ status: "loading", message: "Model Already Loaded" });
39
+ }
40
+ return this.instance[modelID];
41
+ }
42
+ }
43
+
44
+ self.addEventListener("message", async (event) => {
45
+ const { weightsURL, modelID, tokenizerURL, mel_filtersURL, audioURL } =
46
+ event.data;
47
+ try {
48
+ self.postMessage({ status: "decoding", message: "Starting Decoder" });
49
+
50
+ const decoder = await Whisper.getInstance(
51
+ weightsURL,
52
+ modelID,
53
+ tokenizerURL,
54
+ mel_filtersURL
55
+ );
56
+
57
+ self.postMessage({ status: "decoding", message: "Loading Audio" });
58
+ const audioArrayU8 = await fetchArrayBuffer(audioURL);
59
+
60
+ self.postMessage({ status: "decoding", message: "Running Decoder..." });
61
+ const segments = decoder.decode(audioArrayU8);
62
+
63
+ // Send the segment back to the main thread as JSON
64
+ self.postMessage({
65
+ status: "complete",
66
+ message: "complete",
67
+ output: JSON.parse(segments),
68
+ });
69
+ } catch (e) {
70
+ self.postMessage({ error: e });
71
+ }
72
+ });