deepfilternet3-assets 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepfilternet3-assets",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "DeepFilterNet3 WASM and model assets for noise suppression",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/pkg/df.d.ts CHANGED
@@ -1,85 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Create a DeepFilterNet Model
5
- *
6
- * Args:
7
- * - path: File path to a DeepFilterNet tar.gz onnx model
8
- * - atten_lim: Attenuation limit in dB.
9
- *
10
- * Returns:
11
- * - DF state doing the full processing: stft, DNN noise reduction, istft.
12
- * @param {Uint8Array} model_bytes
13
- * @param {number} atten_lim
14
- * @returns {number}
15
- */
16
- export function df_create(model_bytes: Uint8Array, atten_lim: number): number;
17
- /**
18
- * Get DeepFilterNet frame size in samples.
19
- * @param {number} st
20
- * @returns {number}
21
- */
22
- export function df_get_frame_length(st: number): number;
23
- /**
24
- * @param {number} st
25
- * @param {boolean} enabled
26
- * @param {number} desired_output_rms
27
- * @param {number} distortion_factor
28
- * @param {number} snr_thresh
29
- */
30
- export function df_set_agc_params(st: number, enabled: boolean, desired_output_rms: number, distortion_factor: number, snr_thresh: number): void;
31
- /**
32
- * Set DeepFilterNet attenuation limit.
33
- *
34
- * Args:
35
- * - lim_db: New attenuation limit in dB.
36
- * @param {number} st
37
- * @param {number} lim_db
38
- */
39
- export function df_set_atten_lim(st: number, lim_db: number): void;
40
- /**
41
- * Set DeepFilterNet post filter beta. A beta of 0 disables the post filter.
42
- *
43
- * Args:
44
- * - beta: Post filter attenuation. Suitable range between 0.05 and 0;
45
- * @param {number} st
46
- * @param {number} beta
47
- */
48
- export function df_set_post_filter_beta(st: number, beta: number): void;
49
- /**
50
- * Processes a chunk of samples.
51
- *
52
- * Args:
53
- * - df_state: Created via df_create()
54
- * - input: Input buffer of length df_get_frame_length()
55
- * - output: Output buffer of length df_get_frame_length()
56
- *
57
- * Returns:
58
- * - Local SNR of the current frame.
59
- * @param {number} st
60
- * @param {Float32Array} input
61
- * @returns {Float32Array}
62
- */
63
- export function df_process_frame(st: number, input: Float32Array): Float32Array;
64
- /**
65
- */
66
- export class DFState {
67
- free(): void;
68
- }
69
3
 
70
4
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
71
5
 
72
6
  export interface InitOutput {
73
7
  readonly memory: WebAssembly.Memory;
74
- readonly __wbg_dfstate_free: (a: number) => void;
75
- readonly df_create: (a: number, b: number, c: number) => number;
76
- readonly df_get_frame_length: (a: number) => number;
77
- readonly df_process_frame: (a: number, b: number, c: number) => number;
78
- readonly df_set_agc_params: (a: number, b: number, c: number, d: number, e: number) => void;
79
- readonly df_set_atten_lim: (a: number, b: number) => void;
80
- readonly df_set_post_filter_beta: (a: number, b: number) => void;
81
- readonly __wbindgen_malloc: (a: number, b: number) => number;
82
- readonly __wbindgen_exn_store: (a: number) => void;
83
8
  }
84
9
 
85
10
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/pkg/df.js CHANGED
@@ -47,53 +47,64 @@ function addHeapObject(obj) {
47
47
  return idx;
48
48
  }
49
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
+
50
59
  let WASM_VECTOR_LEN = 0;
51
60
 
52
- function passArray8ToWasm0(arg, malloc) {
53
- const ptr = malloc(arg.length * 1, 1) >>> 0;
54
- getUint8Memory0().set(arg, ptr / 1);
61
+ function passArrayF32ToWasm0(arg, malloc) {
62
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
63
+ getFloat32Memory0().set(arg, ptr / 4);
55
64
  WASM_VECTOR_LEN = arg.length;
56
65
  return ptr;
57
66
  }
58
67
  /**
59
- * Create a DeepFilterNet Model
68
+ * Processes a chunk of samples.
60
69
  *
61
70
  * Args:
62
- * - path: File path to a DeepFilterNet tar.gz onnx model
63
- * - atten_lim: Attenuation limit in dB.
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()
64
74
  *
65
75
  * Returns:
66
- * - DF state doing the full processing: stft, DNN noise reduction, istft.
67
- * @param {Uint8Array} model_bytes
68
- * @param {number} atten_lim
69
- * @returns {number}
76
+ * - Local SNR of the current frame.
77
+ * @param {number} st
78
+ * @param {Float32Array} input
79
+ * @returns {Float32Array}
70
80
  */
71
- export function df_create(model_bytes, atten_lim) {
72
- const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
81
+ export function df_process_frame(st, input) {
82
+ const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_export_0);
73
83
  const len0 = WASM_VECTOR_LEN;
74
- const ret = wasm.df_create(ptr0, len0, atten_lim);
75
- return ret >>> 0;
84
+ const ret = wasm.df_process_frame(st, ptr0, len0);
85
+ return takeObject(ret);
76
86
  }
77
87
 
78
88
  /**
79
- * Get DeepFilterNet frame size in samples.
89
+ * Set DeepFilterNet post filter beta. A beta of 0 disables the post filter.
90
+ *
91
+ * Args:
92
+ * - beta: Post filter attenuation. Suitable range between 0.05 and 0;
80
93
  * @param {number} st
81
- * @returns {number}
94
+ * @param {number} beta
82
95
  */
83
- export function df_get_frame_length(st) {
84
- const ret = wasm.df_get_frame_length(st);
85
- return ret >>> 0;
96
+ export function df_set_post_filter_beta(st, beta) {
97
+ wasm.df_set_post_filter_beta(st, beta);
86
98
  }
87
99
 
88
100
  /**
101
+ * Get DeepFilterNet frame size in samples.
89
102
  * @param {number} st
90
- * @param {boolean} enabled
91
- * @param {number} desired_output_rms
92
- * @param {number} distortion_factor
93
- * @param {number} snr_thresh
103
+ * @returns {number}
94
104
  */
95
- export function df_set_agc_params(st, enabled, desired_output_rms, distortion_factor, snr_thresh) {
96
- wasm.df_set_agc_params(st, enabled, desired_output_rms, distortion_factor, snr_thresh);
105
+ export function df_get_frame_length(st) {
106
+ const ret = wasm.df_get_frame_length(st);
107
+ return ret >>> 0;
97
108
  }
98
109
 
99
110
  /**
@@ -108,59 +119,37 @@ export function df_set_atten_lim(st, lim_db) {
108
119
  wasm.df_set_atten_lim(st, lim_db);
109
120
  }
110
121
 
111
- /**
112
- * Set DeepFilterNet post filter beta. A beta of 0 disables the post filter.
113
- *
114
- * Args:
115
- * - beta: Post filter attenuation. Suitable range between 0.05 and 0;
116
- * @param {number} st
117
- * @param {number} beta
118
- */
119
- export function df_set_post_filter_beta(st, beta) {
120
- wasm.df_set_post_filter_beta(st, beta);
121
- }
122
-
123
- let cachedFloat32Memory0 = null;
124
-
125
- function getFloat32Memory0() {
126
- if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) {
127
- cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer);
128
- }
129
- return cachedFloat32Memory0;
130
- }
131
-
132
- function passArrayF32ToWasm0(arg, malloc) {
133
- const ptr = malloc(arg.length * 4, 4) >>> 0;
134
- getFloat32Memory0().set(arg, ptr / 4);
122
+ function passArray8ToWasm0(arg, malloc) {
123
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
124
+ getUint8Memory0().set(arg, ptr / 1);
135
125
  WASM_VECTOR_LEN = arg.length;
136
126
  return ptr;
137
127
  }
138
128
  /**
139
- * Processes a chunk of samples.
129
+ * Create a DeepFilterNet Model
140
130
  *
141
131
  * Args:
142
- * - df_state: Created via df_create()
143
- * - input: Input buffer of length df_get_frame_length()
144
- * - output: Output buffer of length df_get_frame_length()
132
+ * - path: File path to a DeepFilterNet tar.gz onnx model
133
+ * - atten_lim: Attenuation limit in dB.
145
134
  *
146
135
  * Returns:
147
- * - Local SNR of the current frame.
148
- * @param {number} st
149
- * @param {Float32Array} input
150
- * @returns {Float32Array}
136
+ * - DF state doing the full processing: stft, DNN noise reduction, istft.
137
+ * @param {Uint8Array} model_bytes
138
+ * @param {number} atten_lim
139
+ * @returns {number}
151
140
  */
152
- export function df_process_frame(st, input) {
153
- const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_malloc);
141
+ export function df_create(model_bytes, atten_lim) {
142
+ const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_export_0);
154
143
  const len0 = WASM_VECTOR_LEN;
155
- const ret = wasm.df_process_frame(st, ptr0, len0);
156
- return takeObject(ret);
144
+ const ret = wasm.df_create(ptr0, len0, atten_lim);
145
+ return ret >>> 0;
157
146
  }
158
147
 
159
148
  function handleError(f, args) {
160
149
  try {
161
150
  return f.apply(this, args);
162
151
  } catch (e) {
163
- wasm.__wbindgen_exn_store(addHeapObject(e));
152
+ wasm.__wbindgen_export_1(addHeapObject(e));
164
153
  }
165
154
  }
166
155
 
@@ -221,15 +210,15 @@ function __wbg_get_imports() {
221
210
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
222
211
  takeObject(arg0);
223
212
  };
224
- imports.wbg.__wbg_crypto_566d7465cdbb6b7a = function(arg0) {
225
- const ret = getObject(arg0).crypto;
226
- return addHeapObject(ret);
227
- };
228
213
  imports.wbg.__wbindgen_is_object = function(arg0) {
229
214
  const val = getObject(arg0);
230
215
  const ret = typeof(val) === 'object' && val !== null;
231
216
  return ret;
232
217
  };
218
+ imports.wbg.__wbg_crypto_566d7465cdbb6b7a = function(arg0) {
219
+ const ret = getObject(arg0).crypto;
220
+ return addHeapObject(ret);
221
+ };
233
222
  imports.wbg.__wbg_process_dc09a8c7d59982f6 = function(arg0) {
234
223
  const ret = getObject(arg0).process;
235
224
  return addHeapObject(ret);
@@ -250,24 +239,20 @@ function __wbg_get_imports() {
250
239
  const ret = module.require;
251
240
  return addHeapObject(ret);
252
241
  }, arguments) };
253
- imports.wbg.__wbindgen_is_function = function(arg0) {
254
- const ret = typeof(getObject(arg0)) === 'function';
255
- return ret;
242
+ imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) {
243
+ const ret = getObject(arg0).msCrypto;
244
+ return addHeapObject(ret);
256
245
  };
257
246
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
258
247
  const ret = getStringFromWasm0(arg0, arg1);
259
248
  return addHeapObject(ret);
260
249
  };
261
- imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) {
262
- const ret = getObject(arg0).msCrypto;
263
- return addHeapObject(ret);
264
- };
265
- imports.wbg.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) {
266
- getObject(arg0).randomFillSync(takeObject(arg1));
267
- }, arguments) };
268
250
  imports.wbg.__wbg_getRandomValues_260cc23a41afad9a = function() { return handleError(function (arg0, arg1) {
269
251
  getObject(arg0).getRandomValues(getObject(arg1));
270
252
  }, arguments) };
253
+ imports.wbg.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) {
254
+ getObject(arg0).randomFillSync(takeObject(arg1));
255
+ }, arguments) };
271
256
  imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
272
257
  const ret = new Function(getStringFromWasm0(arg0, arg1));
273
258
  return addHeapObject(ret);
@@ -327,14 +312,18 @@ function __wbg_get_imports() {
327
312
  const ret = getObject(arg0).call(getObject(arg1));
328
313
  return addHeapObject(ret);
329
314
  }, arguments) };
330
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
331
- const ret = getObject(arg0);
332
- return addHeapObject(ret);
333
- };
334
315
  imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {
335
316
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
336
317
  return addHeapObject(ret);
337
318
  }, arguments) };
319
+ imports.wbg.__wbindgen_is_function = function(arg0) {
320
+ const ret = typeof(getObject(arg0)) === 'function';
321
+ return ret;
322
+ };
323
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
324
+ const ret = getObject(arg0);
325
+ return addHeapObject(ret);
326
+ };
338
327
  imports.wbg.__wbindgen_memory = function() {
339
328
  const ret = wasm.memory;
340
329
  return addHeapObject(ret);
package/pkg/df_bg.wasm CHANGED
Binary file