Faridzar commited on
Commit
5795a53
·
1 Parent(s): cbb525d

Add DFN3 wasm-pack browser bundle (model + WASM + JS shim)

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +30 -0
  3. deepfilter3_model.tar.gz +3 -0
  4. df.js +388 -0
  5. df_bg.wasm +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - audio
5
+ - noise-suppression
6
+ - deepfilternet
7
+ ---
8
+ # DeepFilterNet3 — wasm-pack browser bundle
9
+
10
+ Mirror of the DeepFilterNet3 WASM browser build used by [timbrica.com](https://timbrica.com)
11
+ `/denoise` and `/audio-enhancer` tools.
12
+
13
+ Created 2026-05-07 because:
14
+ - Upstream [Rikorose/DeepFilterNet GitHub Releases](https://github.com/Rikorose/DeepFilterNet/releases) publish only native CLI/LADSPA artefacts (no wasm-bindgen browser bundle).
15
+ - Upstream [Rikorose/DeepFilterNet3 HF repo](https://huggingface.co/Rikorose/DeepFilterNet3) returns 401 (gated).
16
+ - A self-hosted GitHub Release (`bandidas1/timbrica-models v1-deepfilter-wasm`) was tried but GitHub release-assets do not return CORS headers, blocking cross-origin browser fetch from non-RU pages.
17
+
18
+ HuggingFace serves all files with `Access-Control-Allow-Origin: *` so cross-origin
19
+ `fetch()` and ES `import()` from browser code work without proxy.
20
+
21
+ ## Files
22
+ | File | SHA256 | Size |
23
+ |---|---|---|
24
+ | `deepfilter3_model.tar.gz` | `c94d91f70911001c946e0fabb4aa9adc37045f45a03b56008cb0c8244cb63616` | 7,983,136 |
25
+ | `df_bg.wasm` | `1d2418787212bf1146b7e41798b2906b155b82ed3e23d762dac6fa9903489340` | 8,966,660 |
26
+ | `df.js` | `fcf6e18d9c15d228b2576a6428e6a02f3b1520b0e8e2e7a8f547531e596cb121` | 12,232 |
27
+
28
+ ## License
29
+
30
+ Apache-2.0 / MIT (dual), inherited from [Rikorose/DeepFilterNet](https://github.com/Rikorose/DeepFilterNet).
deepfilter3_model.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c94d91f70911001c946e0fabb4aa9adc37045f45a03b56008cb0c8244cb63616
3
+ size 7983136
df.js ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 cachedFloat32Memory0 = null;
51
+
52
+ function getFloat32Memory0() {
53
+ if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) {
54
+ cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer);
55
+ }
56
+ return cachedFloat32Memory0;
57
+ }
58
+
59
+ let WASM_VECTOR_LEN = 0;
60
+
61
+ function passArrayF32ToWasm0(arg, malloc) {
62
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
63
+ getFloat32Memory0().set(arg, ptr / 4);
64
+ WASM_VECTOR_LEN = arg.length;
65
+ return ptr;
66
+ }
67
+ /**
68
+ * Processes a chunk of samples.
69
+ *
70
+ * Args:
71
+ * - df_state: Created via df_create()
72
+ * - input: Input buffer of length df_get_frame_length()
73
+ * - output: Output buffer of length df_get_frame_length()
74
+ *
75
+ * Returns:
76
+ * - Local SNR of the current frame.
77
+ * @param {number} st
78
+ * @param {Float32Array} input
79
+ * @returns {Float32Array}
80
+ */
81
+ export function df_process_frame(st, input) {
82
+ const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_malloc);
83
+ const len0 = WASM_VECTOR_LEN;
84
+ const ret = wasm.df_process_frame(st, ptr0, len0);
85
+ return takeObject(ret);
86
+ }
87
+
88
+ /**
89
+ * Get DeepFilterNet frame size in samples.
90
+ * @param {number} st
91
+ * @returns {number}
92
+ */
93
+ export function df_get_frame_length(st) {
94
+ const ret = wasm.df_get_frame_length(st);
95
+ return ret >>> 0;
96
+ }
97
+
98
+ function passArray8ToWasm0(arg, malloc) {
99
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
100
+ getUint8Memory0().set(arg, ptr / 1);
101
+ WASM_VECTOR_LEN = arg.length;
102
+ return ptr;
103
+ }
104
+ /**
105
+ * Create a DeepFilterNet Model
106
+ *
107
+ * Args:
108
+ * - path: File path to a DeepFilterNet tar.gz onnx model
109
+ * - atten_lim: Attenuation limit in dB.
110
+ *
111
+ * Returns:
112
+ * - DF state doing the full processing: stft, DNN noise reduction, istft.
113
+ * @param {Uint8Array} model_bytes
114
+ * @param {number} atten_lim
115
+ * @returns {number}
116
+ */
117
+ export function df_create(model_bytes, atten_lim) {
118
+ const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
119
+ const len0 = WASM_VECTOR_LEN;
120
+ const ret = wasm.df_create(ptr0, len0, atten_lim);
121
+ return ret >>> 0;
122
+ }
123
+
124
+ /**
125
+ * Set DeepFilterNet post filter beta. A beta of 0 disables the post filter.
126
+ *
127
+ * Args:
128
+ * - beta: Post filter attenuation. Suitable range between 0.05 and 0;
129
+ * @param {number} st
130
+ * @param {number} beta
131
+ */
132
+ export function df_set_post_filter_beta(st, beta) {
133
+ wasm.df_set_post_filter_beta(st, beta);
134
+ }
135
+
136
+ /**
137
+ * Set DeepFilterNet attenuation limit.
138
+ *
139
+ * Args:
140
+ * - lim_db: New attenuation limit in dB.
141
+ * @param {number} st
142
+ * @param {number} lim_db
143
+ */
144
+ export function df_set_atten_lim(st, lim_db) {
145
+ wasm.df_set_atten_lim(st, lim_db);
146
+ }
147
+
148
+ function handleError(f, args) {
149
+ try {
150
+ return f.apply(this, args);
151
+ } catch (e) {
152
+ wasm.__wbindgen_exn_store(addHeapObject(e));
153
+ }
154
+ }
155
+
156
+ const DFStateFinalization = (typeof FinalizationRegistry === 'undefined')
157
+ ? { register: () => {}, unregister: () => {} }
158
+ : new FinalizationRegistry(ptr => wasm.__wbg_dfstate_free(ptr >>> 0));
159
+ /**
160
+ */
161
+ export class DFState {
162
+
163
+ __destroy_into_raw() {
164
+ const ptr = this.__wbg_ptr;
165
+ this.__wbg_ptr = 0;
166
+ DFStateFinalization.unregister(this);
167
+ return ptr;
168
+ }
169
+
170
+ free() {
171
+ const ptr = this.__destroy_into_raw();
172
+ wasm.__wbg_dfstate_free(ptr);
173
+ }
174
+ }
175
+
176
+ async function __wbg_load(module, imports) {
177
+ if (typeof Response === 'function' && module instanceof Response) {
178
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
179
+ try {
180
+ return await WebAssembly.instantiateStreaming(module, imports);
181
+
182
+ } catch (e) {
183
+ if (module.headers.get('Content-Type') != 'application/wasm') {
184
+ 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);
185
+
186
+ } else {
187
+ throw e;
188
+ }
189
+ }
190
+ }
191
+
192
+ const bytes = await module.arrayBuffer();
193
+ return await WebAssembly.instantiate(bytes, imports);
194
+
195
+ } else {
196
+ const instance = await WebAssembly.instantiate(module, imports);
197
+
198
+ if (instance instanceof WebAssembly.Instance) {
199
+ return { instance, module };
200
+
201
+ } else {
202
+ return instance;
203
+ }
204
+ }
205
+ }
206
+
207
+ function __wbg_get_imports() {
208
+ const imports = {};
209
+ imports.wbg = {};
210
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
211
+ takeObject(arg0);
212
+ };
213
+ imports.wbg.__wbg_crypto_566d7465cdbb6b7a = function(arg0) {
214
+ const ret = getObject(arg0).crypto;
215
+ return addHeapObject(ret);
216
+ };
217
+ imports.wbg.__wbindgen_is_object = function(arg0) {
218
+ const val = getObject(arg0);
219
+ const ret = typeof(val) === 'object' && val !== null;
220
+ return ret;
221
+ };
222
+ imports.wbg.__wbg_process_dc09a8c7d59982f6 = function(arg0) {
223
+ const ret = getObject(arg0).process;
224
+ return addHeapObject(ret);
225
+ };
226
+ imports.wbg.__wbg_versions_d98c6400c6ca2bd8 = function(arg0) {
227
+ const ret = getObject(arg0).versions;
228
+ return addHeapObject(ret);
229
+ };
230
+ imports.wbg.__wbg_node_caaf83d002149bd5 = function(arg0) {
231
+ const ret = getObject(arg0).node;
232
+ return addHeapObject(ret);
233
+ };
234
+ imports.wbg.__wbindgen_is_string = function(arg0) {
235
+ const ret = typeof(getObject(arg0)) === 'string';
236
+ return ret;
237
+ };
238
+ imports.wbg.__wbg_require_94a9da52636aacbf = function() { return handleError(function () {
239
+ const ret = module.require;
240
+ return addHeapObject(ret);
241
+ }, arguments) };
242
+ imports.wbg.__wbindgen_is_function = function(arg0) {
243
+ const ret = typeof(getObject(arg0)) === 'function';
244
+ return ret;
245
+ };
246
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
247
+ const ret = getStringFromWasm0(arg0, arg1);
248
+ return addHeapObject(ret);
249
+ };
250
+ imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) {
251
+ const ret = getObject(arg0).msCrypto;
252
+ return addHeapObject(ret);
253
+ };
254
+ imports.wbg.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) {
255
+ getObject(arg0).randomFillSync(takeObject(arg1));
256
+ }, arguments) };
257
+ imports.wbg.__wbg_getRandomValues_260cc23a41afad9a = function() { return handleError(function (arg0, arg1) {
258
+ getObject(arg0).getRandomValues(getObject(arg1));
259
+ }, arguments) };
260
+ imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
261
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
262
+ return addHeapObject(ret);
263
+ };
264
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
265
+ const ret = new Uint8Array(getObject(arg0));
266
+ return addHeapObject(ret);
267
+ };
268
+ imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) {
269
+ const ret = new Float32Array(getObject(arg0));
270
+ return addHeapObject(ret);
271
+ };
272
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
273
+ const ret = getObject(arg0).buffer;
274
+ return addHeapObject(ret);
275
+ };
276
+ imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
277
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
278
+ return addHeapObject(ret);
279
+ };
280
+ imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {
281
+ const ret = new Uint8Array(arg0 >>> 0);
282
+ return addHeapObject(ret);
283
+ };
284
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
285
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
286
+ };
287
+ imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {
288
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
289
+ return addHeapObject(ret);
290
+ };
291
+ imports.wbg.__wbg_newwithbyteoffsetandlength_4a659d079a1650e0 = function(arg0, arg1, arg2) {
292
+ const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
293
+ return addHeapObject(ret);
294
+ };
295
+ imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {
296
+ const ret = self.self;
297
+ return addHeapObject(ret);
298
+ }, arguments) };
299
+ imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {
300
+ const ret = window.window;
301
+ return addHeapObject(ret);
302
+ }, arguments) };
303
+ imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {
304
+ const ret = globalThis.globalThis;
305
+ return addHeapObject(ret);
306
+ }, arguments) };
307
+ imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () {
308
+ const ret = global.global;
309
+ return addHeapObject(ret);
310
+ }, arguments) };
311
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
312
+ const ret = getObject(arg0) === undefined;
313
+ return ret;
314
+ };
315
+ imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {
316
+ const ret = getObject(arg0).call(getObject(arg1));
317
+ return addHeapObject(ret);
318
+ }, arguments) };
319
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
320
+ const ret = getObject(arg0);
321
+ return addHeapObject(ret);
322
+ };
323
+ imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {
324
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
325
+ return addHeapObject(ret);
326
+ }, arguments) };
327
+ imports.wbg.__wbindgen_memory = function() {
328
+ const ret = wasm.memory;
329
+ return addHeapObject(ret);
330
+ };
331
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
332
+ throw new Error(getStringFromWasm0(arg0, arg1));
333
+ };
334
+
335
+ return imports;
336
+ }
337
+
338
+ function __wbg_init_memory(imports, maybe_memory) {
339
+
340
+ }
341
+
342
+ function __wbg_finalize_init(instance, module) {
343
+ wasm = instance.exports;
344
+ __wbg_init.__wbindgen_wasm_module = module;
345
+ cachedFloat32Memory0 = null;
346
+ cachedUint8Memory0 = null;
347
+
348
+
349
+ return wasm;
350
+ }
351
+
352
+ function initSync(module) {
353
+ if (wasm !== undefined) return wasm;
354
+
355
+ const imports = __wbg_get_imports();
356
+
357
+ __wbg_init_memory(imports);
358
+
359
+ if (!(module instanceof WebAssembly.Module)) {
360
+ module = new WebAssembly.Module(module);
361
+ }
362
+
363
+ const instance = new WebAssembly.Instance(module, imports);
364
+
365
+ return __wbg_finalize_init(instance, module);
366
+ }
367
+
368
+ async function __wbg_init(input) {
369
+ if (wasm !== undefined) return wasm;
370
+
371
+ if (typeof input === 'undefined') {
372
+ input = new URL('df_bg.wasm', import.meta.url);
373
+ }
374
+ const imports = __wbg_get_imports();
375
+
376
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
377
+ input = fetch(input);
378
+ }
379
+
380
+ __wbg_init_memory(imports);
381
+
382
+ const { instance, module } = await __wbg_load(await input, imports);
383
+
384
+ return __wbg_finalize_init(instance, module);
385
+ }
386
+
387
+ export { initSync }
388
+ export default __wbg_init;
df_bg.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d2418787212bf1146b7e41798b2906b155b82ed3e23d762dac6fa9903489340
3
+ size 8966660