@cc-livekit/audio-pipeline-plugin 1.1.2 → 1.1.4

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.
@@ -1 +1 @@
1
- "undefined"==typeof self&&(globalThis.self=globalThis),(()=>{"use strict";var e={807:(e,t,n)=>{let r;n.d(t,{A:()=>o}),e=n.hmd(e),function(){const t={};let o,i;"undefined"!=typeof document&&null!==document.currentScript&&(o=new URL(document.currentScript.src,location.href).toString());const a=new Array(128).fill(void 0);function s(e){return a[e]}a.push(void 0,null,!0,!1);let l=a.length;function c(e){const t=s(e);return function(e){e<132||(a[e]=l,l=e)}(e),t}const d="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&d.decode();let u=null;function f(){return null!==u&&0!==u.byteLength||(u=new Uint8Array(i.memory.buffer)),u}function _(e,t){return e>>>=0,d.decode(f().subarray(e,e+t))}function m(e){l===a.length&&a.push(a.length+1);const t=l;return l=a[t],a[t]=e,t}let p=0;t.df_create=function(e,t){const n=function(e,t){const n=t(1*e.length,1)>>>0;return f().set(e,n/1),p=e.length,n}(e,i.__wbindgen_malloc),r=p;return i.df_create(n,r,t)>>>0},t.df_destroy=function(e){i.df_destroy(e)},t.df_set_atten_lim=function(e,t){i.df_set_atten_lim(e,t)};let g=null;function b(e,t){try{return e.apply(this,t)}catch(e){i.__wbindgen_exn_store(m(e))}}t.df_process_frame=function(e,t){const n=function(e,t){const n=t(4*e.length,4)>>>0;return(null!==g&&0!==g.byteLength||(g=new Float32Array(i.memory.buffer)),g).set(e,n/4),p=e.length,n}(t,i.__wbindgen_malloc),r=p;return c(i.df_process_frame(e,n,r))},t.df_set_post_filter_beta=function(e,t){i.df_set_post_filter_beta(e,t)},t.df_get_lookahead=function(e){return i.df_get_lookahead(e)>>>0},t.df_get_frame_length=function(e){return i.df_get_frame_length(e)>>>0},t.df_create_default=function(e){return i.df_create_default(e)>>>0};const h="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>i.__wbg_dfstate_free(e>>>0)));function y(){const t={wbg:{}};return t.wbg.__wbindgen_object_drop_ref=function(e){c(e)},t.wbg.__wbg_crypto_566d7465cdbb6b7a=function(e){return m(s(e).crypto)},t.wbg.__wbindgen_is_object=function(e){const t=s(e);return"object"==typeof t&&null!==t},t.wbg.__wbg_process_dc09a8c7d59982f6=function(e){return m(s(e).process)},t.wbg.__wbg_versions_d98c6400c6ca2bd8=function(e){return m(s(e).versions)},t.wbg.__wbg_node_caaf83d002149bd5=function(e){return m(s(e).node)},t.wbg.__wbindgen_is_string=function(e){return"string"==typeof s(e)},t.wbg.__wbg_require_94a9da52636aacbf=function(){return b((function(){return m(e.require)}),arguments)},t.wbg.__wbindgen_is_function=function(e){return"function"==typeof s(e)},t.wbg.__wbindgen_string_new=function(e,t){return m(_(e,t))},t.wbg.__wbg_msCrypto_0b84745e9245cdf6=function(e){return m(s(e).msCrypto)},t.wbg.__wbg_randomFillSync_290977693942bf03=function(){return b((function(e,t){s(e).randomFillSync(c(t))}),arguments)},t.wbg.__wbg_getRandomValues_260cc23a41afad9a=function(){return b((function(e,t){s(e).getRandomValues(s(t))}),arguments)},t.wbg.__wbg_newnoargs_e258087cd0daa0ea=function(e,t){return m(new Function(_(e,t)))},t.wbg.__wbg_new_63b92bc8671ed464=function(e){return m(new Uint8Array(s(e)))},t.wbg.__wbg_new_9efabd6b6d2ce46d=function(e){return m(new Float32Array(s(e)))},t.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){return m(s(e).buffer)},t.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(e,t,n){return m(new Uint8Array(s(e),t>>>0,n>>>0))},t.wbg.__wbg_newwithlength_e9b4878cebadb3d3=function(e){return m(new Uint8Array(e>>>0))},t.wbg.__wbg_set_a47bac70306a19a7=function(e,t,n){s(e).set(s(t),n>>>0)},t.wbg.__wbg_subarray_a1f73cd4b5b42fe1=function(e,t,n){return m(s(e).subarray(t>>>0,n>>>0))},t.wbg.__wbg_newwithbyteoffsetandlength_4a659d079a1650e0=function(e,t,n){return m(new Float32Array(s(e),t>>>0,n>>>0))},t.wbg.__wbg_self_ce0dbfc45cf2f5be=function(){return b((function(){return m(self.self)}),arguments)},t.wbg.__wbg_window_c6fb939a7f436783=function(){return b((function(){return m(window.window)}),arguments)},t.wbg.__wbg_globalThis_d1e6af4856ba331b=function(){return b((function(){return m(globalThis.globalThis)}),arguments)},t.wbg.__wbg_global_207b558942527489=function(){return b((function(){return m(n.g.global)}),arguments)},t.wbg.__wbindgen_is_undefined=function(e){return void 0===s(e)},t.wbg.__wbg_call_27c0f87801dedf93=function(){return b((function(e,t){return m(s(e).call(s(t)))}),arguments)},t.wbg.__wbindgen_object_clone_ref=function(e){return m(s(e))},t.wbg.__wbg_call_b3ca7c6051f9bec1=function(){return b((function(e,t,n){return m(s(e).call(s(t),s(n)))}),arguments)},t.wbg.__wbindgen_memory=function(){return m(i.memory)},t.wbg.__wbindgen_throw=function(e,t){throw new Error(_(e,t))},t}function w(e,t){return i=e.exports,E.__wbindgen_wasm_module=t,g=null,u=null,i}async function E(e){if(void 0!==i)return i;void 0===e&&void 0!==o&&(e=o.replace(/\.js$/,"_bg.wasm"));const t=y();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:n,module:r}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;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",t)}const n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await e,t);return w(n,r)}t.DFState=class{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,h.unregister(this),e}free(){const e=this.__destroy_into_raw();i.__wbg_dfstate_free(e)}},r=Object.assign(E,{initSync:function(e){if(void 0!==i)return i;const t=y();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),w(new WebAssembly.Instance(e,t),e)}},t)}();const o=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r](i,i.exports,n),i.loaded=!0,i.exports}function r(e){return e?e.slice(0):void 0}function o(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function i(e){if("string"!=typeof e)return;const t=e.trim();return 0!==t.length?t:void 0}function a(e){return"deepfilternet"===e?"deepfilternet":"rnnoise"}function s(e){return!Number.isFinite(e)||(e??0)<=0?1e3:e??1e3}function l(e){return Number.isFinite(e)?Math.max(0,e??0):0}function c(e){return{vadLogs:Boolean(e?.vadLogs),bufferOverflowMs:s(e?.bufferOverflowMs)}}function d(e,t){return t?{vadLogs:t.vadLogs??e.vadLogs,bufferOverflowMs:void 0!==t.bufferOverflowMs?s(t.bufferOverflowMs):e.bufferOverflowMs}:{...e}}function u(e,t){if(!t)return{...e,modelBytes:r(e.modelBytes)};let n=i(e.modelUrl),o=r(e.modelBytes);if(!0===t.clearModel&&(n=void 0,o=void 0),void 0!==t.modelUrl&&(n=i(t.modelUrl),o=void 0),void 0!==t.modelBuffer){if(t.modelBuffer.byteLength<=0)throw new Error("DeepFilter modelBuffer is empty");o=new Uint8Array(t.modelBuffer.slice(0))}return{modelUrl:n,modelBytes:o,attenLimDb:void 0!==t.attenLimDb?(a=t.attenLimDb,Number.isFinite(a)?Math.abs(a??100):100):e.attenLimDb,postFilterBeta:void 0!==t.postFilterBeta?l(t.postFilterBeta):e.postFilterBeta};var a}n.m=e,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.b=self.location+"";class f{_pool=[];_frameSize;constructor(e,t=8){this._frameSize=e;for(let n=0;n<t;n++)this._pool.push(new Float32Array(e))}acquire(){return this._pool.pop()??new Float32Array(this._frameSize)}release(e){e.length===this._frameSize&&0!==e.buffer.byteLength&&this._pool.push(e)}resize(e){return e===this._frameSize?this:new f(e,this._pool.length||8)}}class _{_config;constructor(e){this._config=e}}class m extends _{}let p,g=!1;function b(e){g||(p=n(807).A,p.initSync(e),g=!0)}class h extends m{moduleId="deepfilternet";_bindings;_state=0;_frameLength=0;_lookahead=0;_disposed=!1;constructor(e,t){if(super({...e,modelBytes:r(e.modelBytes)}),t&&b(t),!p)throw new Error("DeepFilter WASM not initialized. Provide deepfilterWasm in INIT_PIPELINE.");this._bindings=p,this._createState(this._config)}get frameLength(){return this._frameLength}get lookahead(){return this._lookahead}processFrame(e,t){const n=this._bindings.df_process_frame(this._state,e);if(n.length!==this._frameLength)throw new Error(`DeepFilterNet returned invalid frame size. expected=${this._frameLength}, actual=${n.length}`);t.set(n)}updateConfig(e){const t={...e,modelBytes:r(e.modelBytes)},n=!o(this._config.modelBytes,t.modelBytes);this._config=t,n?this._createState(t):(this._bindings.df_set_atten_lim(this._state,t.attenLimDb),this._bindings.df_set_post_filter_beta(this._state,t.postFilterBeta))}dispose(){this._disposed||(this._disposed=!0,this._state&&(this._bindings.df_destroy(this._state),this._state=0))}_createState(e){this._state&&(this._bindings.df_destroy(this._state),this._state=0);const t=r(e.modelBytes);if(this._state=t?this._bindings.df_create(t,e.attenLimDb):this._bindings.df_create_default(e.attenLimDb),!this._state)throw new Error("Failed to create DeepFilterNet state");const n=this._bindings.df_get_frame_length(this._state);if(!Number.isFinite(n)||n<=0)throw this._bindings.df_destroy(this._state),this._state=0,new Error(`Invalid DeepFilterNet frame length: ${n}`);this._frameLength=n,this._lookahead=this._bindings.df_get_lookahead(this._state),this._bindings.df_set_atten_lim(this._state,e.attenLimDb),this._bindings.df_set_post_filter_beta(this._state,e.postFilterBeta)}}var y,w,E=(y="file:///Users/luke/workspace/project/denoise-plugin/js/src/dist/rnnoise-sync.js",function(e={}){var t,r,o,i,a=e,s=(new Promise(((e,t)=>{r=e,o=t})),"object"==typeof window),l="undefined"!=typeof WorkerGlobalScope,c="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&"renderer"!=process.type,d=!s&&!c&&!l,u=Object.assign({},a),f="";if(d){if("object"==typeof process||"object"==typeof window||"undefined"!=typeof WorkerGlobalScope)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");i=e=>{if("function"==typeof readbuffer)return new Uint8Array(readbuffer(e));let t=read(e,"binary");return v("object"==typeof t),t},globalThis.clearTimeout??=e=>{},globalThis.setTimeout??=e=>e(),globalThis.arguments||globalThis.scriptArgs,"undefined"!=typeof print&&(globalThis.console??={},console.log=print,console.warn=console.error=globalThis.printErr??print)}else{if(!s&&!l)throw new Error("environment detection error");if(l?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),y&&(f=y),f=f.startsWith("blob:")?"":f.slice(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1),"object"!=typeof window&&"undefined"==typeof WorkerGlobalScope)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");l&&(i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})}var _,m=a.print||console.log.bind(console),p=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,_="fetchSettings",Object.getOwnPropertyDescriptor(a,_)&&N(`\`Module.${_}\` was supplied but \`${_}\` not included in INCOMING_MODULE_JS_API`),a.arguments&&a.arguments,F("arguments","arguments_"),a.thisProgram&&a.thisProgram,F("thisProgram","thisProgram"),v(void 0===a.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.read,"Module.read option was removed"),v(void 0===a.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),v(void 0===a.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),v(void 0===a.setWindowTitle,"Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),v(void 0===a.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),F("asm","wasmExports"),F("readAsync","readAsync"),F("readBinary","readBinary"),F("setWindowTitle","setWindowTitle"),v(!c,"node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.");var g,b=a.wasmBinary;F("wasmBinary","wasmBinary"),"object"!=typeof WebAssembly&&p("no native wasm support detected");var h,w,E=!1;function v(e,t){e||N("Assertion failed"+(t?": "+t:""))}var T=!1;function S(){if(!E){var e=ee();0==e&&(e+=4);var t=w[e>>>2>>>0],n=w[e+4>>>2>>>0];34821223==t&&2310721022==n||N(`Stack overflow! Stack cookie has been overwritten at ${H(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${H(n)} ${H(t)}`),1668509029!=w[0]&&N("Runtime error: The application has corrupted its heap memory area (address zero)!")}}if((()=>{var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})(),a.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");function F(e,t,n=!0){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,get(){N(`\`Module.${e}\` has been replaced by \`${t}\``+(n?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":""))}})}function A(e){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,set(){N(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function L(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}function I(e,t){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get(){t()}})}function M(e,t){I(e,(()=>{z(`\`${e}\` is not longer defined by emscripten. ${t}`)}))}function R(e){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,get(){var t=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;L(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),N(t)}})}function O(){var e=g.buffer;a.HEAP8=new Int8Array(e),a.HEAP16=new Int16Array(e),a.HEAPU8=h=new Uint8Array(e),a.HEAPU16=new Uint16Array(e),a.HEAP32=new Int32Array(e),a.HEAPU32=w=new Uint32Array(e),a.HEAPF32=new Float32Array(e),a.HEAPF64=new Float64Array(e),a.HEAP64=new BigInt64Array(e),a.HEAPU64=new BigUint64Array(e)}M("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),M("asm","Please use wasmExports instead"),v(!a.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),v("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),v(!a.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),v(!a.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");var P=0,C=null,k={},D=null;function N(e){a.onAbort?.(e),p(e="Aborted("+e+")"),E=!0;var t=new WebAssembly.RuntimeError(e);throw o(t),t}var U,x={error(){N("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init(){x.error()},createDataFile(){x.error()},createPreloadedFile(){x.error()},createLazyFile(){x.error()},open(){x.error()},mkdev(){x.error()},registerDevice(){x.error()},analyzePath(){x.error()},ErrnoError(){x.error()}};function B(e,t){return(...n)=>{v(T,`native function \`${e}\` called before runtime initialization`);var r=Z[e];return v(r,`exported native function \`${e}\` not found`),v(n.length<=t,`native function \`${e}\` called with ${n.length} args but expects ${t}`),r(...n)}}a.FS_createDataFile=x.createDataFile,a.FS_createPreloadedFile=x.createPreloadedFile;var W=e=>{for(;e.length>0;)e.shift()(a)},j=[],G=[];a.noExitRuntime;var $,H=e=>(v("number"==typeof e),"0x"+e.toString(16).padStart(8,"0")),z=e=>{z.shown||={},z.shown[e]||(z.shown[e]=1,p(e))},Y="undefined"!=typeof TextDecoder?new TextDecoder:void 0,V=(e,t=0,n=NaN)=>{for(var r=(t>>>=0)+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.buffer&&Y)return Y.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if(224==(240&a)?a=(15&a)<<12|s<<6|l:(240!=(248&a)&&z("Invalid UTF-8 leading byte "+H(a)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),a=(7&a)<<18|s<<12|l<<6|63&e[t++]),a<65536)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},q=(e,t)=>(v("number"==typeof e,`UTF8ToString expects a number (got ${typeof e})`),(e>>>=0)?V(h,e,t):""),J=e=>{var t=g.buffer,n=(e-t.byteLength+65535)/65536|0;try{return g.grow(n),O(),1}catch(n){p(`growMemory: Attempted to grow heap from ${t.byteLength} bytes to ${e} bytes, but got error: ${n}`)}},K=[null,[],[]],X={__assert_fail:function(e,t,n,r){return t>>>=0,r>>>=0,N(`Assertion failed: ${q(e>>>=0)}, at: `+[t?q(t):"unknown filename",n,r?q(r):"unknown function"])},emscripten_resize_heap:function(e){e>>>=0;var t=h.length;v(e>t);var n,r=4294901760;if(e>r)return p(`Cannot enlarge memory, requested ${e} bytes, but the limit is 4294901760 bytes!`),!1;for(var o=1;o<=4;o*=2){var i=t*(1+.2/o);i=Math.min(i,e+100663296);var a=Math.min(r,(n=Math.max(e,i),v(65536,"alignment argument is required"),65536*Math.ceil(n/65536)));if(J(a))return!0}return p(`Failed to grow the heap from ${t} bytes to ${a} bytes, not enough memory!`),!1},fd_write:function(e,t,n,r){t>>>=0,n>>>=0,r>>>=0;for(var o=0,i=0;i<n;i++){var a=w[t>>>2>>>0],s=w[t+4>>>2>>>0];t+=8;for(var l=0;l<s;l++)c=e,d=h[a+l>>>0],u=void 0,v(u=K[c]),0===d||10===d?((1===c?m:p)(V(u)),u.length=0):u.push(d);o+=s}var c,d,u;return w[r>>>2>>>0]=o,0}},Z=function(){function e(e,t){return Z=function(e){var t,n=e=>t=>e(t)>>>0,r=e=>()=>e()>>>0;return(e=Object.assign({},e)).malloc=n(e.malloc),e.strerror=(t=e.strerror,e=>t(e)>>>0),e.emscripten_stack_get_base=r(e.emscripten_stack_get_base),e.emscripten_stack_get_end=r(e.emscripten_stack_get_end),e._emscripten_stack_alloc=n(e._emscripten_stack_alloc),e.emscripten_stack_get_current=r(e.emscripten_stack_get_current),e}(Z=e.exports),v(g=Z.memory,"memory not found in wasm exports"),O(),function(e){if(P--,a.monitorRunDependencies?.(P),e?(v(k[e]),delete k[e]):p("warning: run dependency removed without ID"),0==P&&(null!==D&&(clearInterval(D),D=null),C)){var t=C;C=null,t()}}("wasm-instantiate"),Z}var t;t="wasm-instantiate",P++,a.monitorRunDependencies?.(P),t?(v(!k[t]),k[t]=1,null===D&&"undefined"!=typeof setInterval&&(D=setInterval((()=>{if(E)return clearInterval(D),void(D=null);var e=!1;for(var t in k)e||(e=!0,p("still waiting on run dependencies:")),p(`dependency: ${t}`);e&&p("(end of list)")}),1e4))):p("warning: run dependency added without ID");var r,o={env:X,wasi_snapshot_preview1:X};return a.instantiateWasm?new Promise(((t,n)=>{try{a.instantiateWasm(o,((n,r)=>{e(n),t(n.exports)}))}catch(e){p(`Module.instantiateWasm callback failed with error: ${e}`),n(e)}})):(U??=a.locateFile?(r="rnnoise-sync.wasm",a.locateFile?a.locateFile(r,f):f+r):d?"rnnoise-sync.wasm":new URL(Object(function(){var e=new Error("Cannot find module 'rnnoise-sync.wasm'");throw e.code="MODULE_NOT_FOUND",e}()),n.b).href,e(function(e,t){var n,r=function(e){if(e==U&&b)return new Uint8Array(b);if(i)return i(e);throw'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)'}(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}(U,o)[0]))}(),Q=(B("__wasm_call_ctors",0),a._malloc=B("malloc",1),a._free=B("free",1),a._rnnoise_init=B("rnnoise_init",2),a._rnnoise_create=B("rnnoise_create",1),a._rnnoise_destroy=B("rnnoise_destroy",1),a._rnnoise_process_frame=B("rnnoise_process_frame",3),B("fflush",1),B("strerror",1),Z.emscripten_stack_init),ee=(Z.emscripten_stack_get_free,Z.emscripten_stack_get_base,Z.emscripten_stack_get_end);if(Z._emscripten_stack_restore,Z._emscripten_stack_alloc,Z.emscripten_stack_get_current,["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","stackAlloc","getTempRet0","setTempRet0","zeroMemory","exitJS","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","emscriptenLog","readEmAsmArgs","jstoi_q","getExecutableName","listenOnce","autoResumeAudioContext","getDynCaller","dynCall","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","asyncLoad","mmapAlloc","HandleAllocator","getNativeTypeSize","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","getEnvStrings","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","initRandomFill","randomFill","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","ExceptionInfo","findMatchingCatch","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar","FS_unlink","FS_createDataFile","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","setErrNo","demangle","stackTrace"].forEach((function(e){I(e,(()=>{var t=`\`${e}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,n=e;n.startsWith("_")||(n="$"+e),t+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${n}')`,L(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),z(t)})),R(e)})),["run","addRunDependency","removeRunDependency","out","err","callMain","abort","wasmMemory","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","stackSave","stackRestore","ptrToString","getHeapMax","growMemory","ENV","ERRNO_CODES","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","jstoi_s","alignMemory","wasmTable","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","UTF16Decoder","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","flush_NO_FILESYSTEM","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","Browser","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","preloadPlugins","FS_stdin_getChar_buffer","FS_createPath","FS_createDevice","FS_readFile","FS","FS_createLazyFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack","print","printErr"].forEach(R),a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();A("preInit"),function e(){function t(){v(!$),$=!0,a.calledRun=!0,E||(v(!T),T=!0,S(),Z.__wasm_call_ctors(),r(a),a.onRuntimeInitialized?.(),A("onRuntimeInitialized"),v(!a._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(S(),a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)e=a.postRun.shift(),j.unshift(e);var e;A("postRun"),W(j)}())}var n;P>0?C=e:(Q(),v(!(3&(n=ee()))),0==n&&(n+=4),w[n>>>2>>>0]=34821223,w[n+4>>>2>>>0]=2310721022,w[0]=1668509029,function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)e=a.preRun.shift(),G.unshift(e);var e;A("preRun"),W(G)}(),P>0?C=e:(a.setStatus?(a.setStatus("Running..."),setTimeout((()=>{setTimeout((()=>a.setStatus("")),1),t()}),1)):t(),S()))}(),t=a;for(const t of Object.keys(a))t in e||Object.defineProperty(e,t,{configurable:!0,get(){N(`Access to module property ('${t}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return t});w=E;const v=E=function(e){if(new.target)throw new Error("createRNNWasmModuleSync() should not be called with `new createRNNWasmModuleSync()`");return w(e)},T=480;class S extends m{moduleId="rnnoise";frameLength=T;_module;_context;_inputPtr;_outputPtr;_inputHeap;_outputHeap;_disposed=!1;constructor(e,t){if(super(e),this._module=v(t?{wasmBinary:t,locateFile:()=>"rnnoise-sync.wasm"}:{}),this._context=this._module._rnnoise_create(),!this._context)throw new Error("Failed to initialize RNNoise context");if(this._inputPtr=this._module._malloc(T*Float32Array.BYTES_PER_ELEMENT),this._outputPtr=this._module._malloc(T*Float32Array.BYTES_PER_ELEMENT),!this._inputPtr||!this._outputPtr)throw this._inputPtr&&this._module._free(this._inputPtr),this._outputPtr&&this._module._free(this._outputPtr),this._module._rnnoise_destroy(this._context),new Error("Failed to allocate RNNoise heap buffers");const n=this._inputPtr>>2,r=this._outputPtr>>2;this._inputHeap=this._module.HEAPF32.subarray(n,n+T),this._outputHeap=this._module.HEAPF32.subarray(r,r+T)}processFrame(e,t){for(let t=0;t<T;t+=1)this._inputHeap[t]=32768*e[t];const n=this._module._rnnoise_process_frame(this._context,this._outputPtr,this._inputPtr),r=1/32768;for(let e=0;e<T;e+=1)t[e]=this._outputHeap[e]*r;return n}updateConfig(e){this._config={...e}}dispose(){this._disposed||(this._disposed=!0,this._module._rnnoise_destroy(this._context),this._module._free(this._inputPtr),this._module._free(this._outputPtr))}}let F,A,L,I,M,R,O=!1,P="rnnoise",C=!0,k=c(),D={modelUrl:void 0,modelBytes:void 0,attenLimDb:100,postFilterBeta:0},N=new f(480,8);const U="[AudioPipeline:Worker]";function x(e,t){O&&F?.postMessage({type:"LOG",level:"info",tag:U,text:e,data:t})}function B(e,t){F?.postMessage(e,t??[])}function W(e){const t=e instanceof Error?e.message:String(e);var n;n=t,F?.postMessage({type:"LOG",level:"error",tag:U,text:n,data:undefined}),B({type:"ERROR",error:t})}function j(e){return e&&e.byteLength>0?e.slice(0):void 0}function G(){return"deepfilternet"===P?R:M}function $(e){P=e;const t=G();return N=N.resize(t.frameLength),x(`MODULE_ACTIVE:${e}`,{frameLength:t.frameLength}),{frameLength:t.frameLength,lookahead:t instanceof h?t.lookahead:0}}function H(){if(!R)return;const e=!o(I,D.modelBytes);if(R.updateConfig(D),e){I=r(D.modelBytes);const e=R.frameLength;"deepfilternet"===P&&(N=N.resize(e),B({type:"MODULE_CHANGED",frameLength:e,lookahead:R.lookahead}))}}function z(e){const t=e.data;if(t?.type)try{switch(t.type){case"INIT":!function(e){const t=performance.now();var n;O=e.debugLogs??!1,P=a(e.moduleId),(n=e.wasmBinaries)&&(n.rnnoiseWasm&&(A=n.rnnoiseWasm.slice(0)),n.deepfilterWasm&&(L=n.deepfilterWasm.slice(0),b(n.deepfilterWasm))),k=d(c(),e.moduleConfigs?.rnnoise),D=u({modelUrl:void 0,modelBytes:void 0,attenLimDb:100,postFilterBeta:0},e.moduleConfigs?.deepfilternet),function(){const e=performance.now();M||(M=new S(k,j(A)),x("PRE_INIT rnnoise",{elapsed:`${(performance.now()-e).toFixed(2)}ms`}));const t=performance.now();R||(R=new h(D,j(L)),I=r(D.modelBytes),x("PRE_INIT deepfilternet",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})),x("PRE_INIT all modules done",{totalElapsed:`${(performance.now()-e).toFixed(2)}ms`})}();const o=$(P);B({type:"INIT_OK",frameLength:o.frameLength,lookahead:o.lookahead}),x("WORKER_READY",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})}(t);break;case"PROCESS_FRAME":!function(e){const t=e.inputBuffer,n=G();if(!C||!n){const e=N.acquire();return e.set(t.length<=e.length?t:t.subarray(0,e.length)),void B({type:"FRAME_RESULT",outputBuffer:e},[e.buffer])}const r=n.frameLength,o=Math.floor(t.length/r);if(o<=0)W(`Input buffer too small: ${t.length} < ${r}`);else try{const e=new Float32Array(r);for(let i=0;i<o;i++){const o=i*r;e.set(t.subarray(o,o+r));const a=N.acquire();B({type:"FRAME_RESULT",outputBuffer:a,vadScore:n.processFrame(e,a)},[a.buffer])}}catch(e){W(e)}}(t);break;case"SET_MODULE":!function(e){const t=performance.now(),n=a(e.moduleId);if(e.config?.rnnoise&&(k=d(k,e.config.rnnoise),M?.updateConfig(k)),e.config?.deepfilternet&&(D=u(D,e.config.deepfilternet),R&&H()),n===P)return void x("SET_MODULE (same module, config only)",{moduleId:n,elapsed:`${(performance.now()-t).toFixed(2)}ms`});const r=$(n);x("SET_MODULE (switch)",{to:n,elapsed:`${(performance.now()-t).toFixed(2)}ms`}),B({type:"MODULE_CHANGED",frameLength:r.frameLength,lookahead:r.lookahead})}(t);break;case"SET_CONFIG":!function(e){const t=performance.now();if("rnnoise"===e.moduleId)return k=d(k,e.config),M?.updateConfig(k),void x("SET_CONFIG rnnoise",{elapsed:`${(performance.now()-t).toFixed(2)}ms`});D=u(D,e.config),R&&H(),x("SET_CONFIG deepfilternet",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})}(t);break;case"SET_ENABLED":C=t.enable,x(t.enable?"PROCESSING_ENABLED":"PROCESSING_DISABLED");break;case"DESTROY":M?.dispose(),R?.dispose(),M=void 0,R=void 0,x("WORKER_DESTROYED")}}catch(e){W(e)}}globalThis.onmessage=e=>{const t=e.data;if("CONNECT_PORT"===t?.type)return F=t.port,F.onmessage=z,void x("WORKER_PORT_CONNECTED");"SET_DEBUG"!==t?.type||(O=Boolean(t.debugLogs))}})();
1
+ "undefined"==typeof self&&(globalThis.self=globalThis),(()=>{"use strict";var e={807:(e,t,n)=>{let r;n.d(t,{A:()=>o}),e=n.hmd(e),function(){const t={};let o,i;"undefined"!=typeof document&&null!==document.currentScript&&(o=new URL(document.currentScript.src,location.href).toString());const a=new Array(128).fill(void 0);function s(e){return a[e]}a.push(void 0,null,!0,!1);let l=a.length;function c(e){const t=s(e);return function(e){e<132||(a[e]=l,l=e)}(e),t}const d="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&d.decode();let u=null;function f(){return null!==u&&0!==u.byteLength||(u=new Uint8Array(i.memory.buffer)),u}function _(e,t){return e>>>=0,d.decode(f().subarray(e,e+t))}function m(e){l===a.length&&a.push(a.length+1);const t=l;return l=a[t],a[t]=e,t}let p=0;t.df_create=function(e,t){const n=function(e,t){const n=t(1*e.length,1)>>>0;return f().set(e,n/1),p=e.length,n}(e,i.__wbindgen_malloc),r=p;return i.df_create(n,r,t)>>>0},t.df_destroy=function(e){i.df_destroy(e)},t.df_set_atten_lim=function(e,t){i.df_set_atten_lim(e,t)};let g=null;function b(e,t){try{return e.apply(this,t)}catch(e){i.__wbindgen_exn_store(m(e))}}t.df_process_frame=function(e,t){const n=function(e,t){const n=t(4*e.length,4)>>>0;return(null!==g&&0!==g.byteLength||(g=new Float32Array(i.memory.buffer)),g).set(e,n/4),p=e.length,n}(t,i.__wbindgen_malloc),r=p;return c(i.df_process_frame(e,n,r))},t.df_set_post_filter_beta=function(e,t){i.df_set_post_filter_beta(e,t)},t.df_get_lookahead=function(e){return i.df_get_lookahead(e)>>>0},t.df_get_frame_length=function(e){return i.df_get_frame_length(e)>>>0},t.df_create_default=function(e){return i.df_create_default(e)>>>0};const h="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e=>i.__wbg_dfstate_free(e>>>0)));function w(){const t={wbg:{}};return t.wbg.__wbindgen_object_drop_ref=function(e){c(e)},t.wbg.__wbg_crypto_566d7465cdbb6b7a=function(e){return m(s(e).crypto)},t.wbg.__wbindgen_is_object=function(e){const t=s(e);return"object"==typeof t&&null!==t},t.wbg.__wbg_process_dc09a8c7d59982f6=function(e){return m(s(e).process)},t.wbg.__wbg_versions_d98c6400c6ca2bd8=function(e){return m(s(e).versions)},t.wbg.__wbg_node_caaf83d002149bd5=function(e){return m(s(e).node)},t.wbg.__wbindgen_is_string=function(e){return"string"==typeof s(e)},t.wbg.__wbg_require_94a9da52636aacbf=function(){return b((function(){return m(e.require)}),arguments)},t.wbg.__wbindgen_is_function=function(e){return"function"==typeof s(e)},t.wbg.__wbindgen_string_new=function(e,t){return m(_(e,t))},t.wbg.__wbg_msCrypto_0b84745e9245cdf6=function(e){return m(s(e).msCrypto)},t.wbg.__wbg_randomFillSync_290977693942bf03=function(){return b((function(e,t){s(e).randomFillSync(c(t))}),arguments)},t.wbg.__wbg_getRandomValues_260cc23a41afad9a=function(){return b((function(e,t){s(e).getRandomValues(s(t))}),arguments)},t.wbg.__wbg_newnoargs_e258087cd0daa0ea=function(e,t){return m(new Function(_(e,t)))},t.wbg.__wbg_new_63b92bc8671ed464=function(e){return m(new Uint8Array(s(e)))},t.wbg.__wbg_new_9efabd6b6d2ce46d=function(e){return m(new Float32Array(s(e)))},t.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){return m(s(e).buffer)},t.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(e,t,n){return m(new Uint8Array(s(e),t>>>0,n>>>0))},t.wbg.__wbg_newwithlength_e9b4878cebadb3d3=function(e){return m(new Uint8Array(e>>>0))},t.wbg.__wbg_set_a47bac70306a19a7=function(e,t,n){s(e).set(s(t),n>>>0)},t.wbg.__wbg_subarray_a1f73cd4b5b42fe1=function(e,t,n){return m(s(e).subarray(t>>>0,n>>>0))},t.wbg.__wbg_newwithbyteoffsetandlength_4a659d079a1650e0=function(e,t,n){return m(new Float32Array(s(e),t>>>0,n>>>0))},t.wbg.__wbg_self_ce0dbfc45cf2f5be=function(){return b((function(){return m(self.self)}),arguments)},t.wbg.__wbg_window_c6fb939a7f436783=function(){return b((function(){return m(window.window)}),arguments)},t.wbg.__wbg_globalThis_d1e6af4856ba331b=function(){return b((function(){return m(globalThis.globalThis)}),arguments)},t.wbg.__wbg_global_207b558942527489=function(){return b((function(){return m(n.g.global)}),arguments)},t.wbg.__wbindgen_is_undefined=function(e){return void 0===s(e)},t.wbg.__wbg_call_27c0f87801dedf93=function(){return b((function(e,t){return m(s(e).call(s(t)))}),arguments)},t.wbg.__wbindgen_object_clone_ref=function(e){return m(s(e))},t.wbg.__wbg_call_b3ca7c6051f9bec1=function(){return b((function(e,t,n){return m(s(e).call(s(t),s(n)))}),arguments)},t.wbg.__wbindgen_memory=function(){return m(i.memory)},t.wbg.__wbindgen_throw=function(e,t){throw new Error(_(e,t))},t}function y(e,t){return i=e.exports,E.__wbindgen_wasm_module=t,g=null,u=null,i}async function E(e){if(void 0!==i)return i;void 0===e&&void 0!==o&&(e=o.replace(/\.js$/,"_bg.wasm"));const t=w();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:n,module:r}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;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",t)}const n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}{const n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}(await e,t);return y(n,r)}t.DFState=class{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,h.unregister(this),e}free(){const e=this.__destroy_into_raw();i.__wbg_dfstate_free(e)}},r=Object.assign(E,{initSync:function(e){if(void 0!==i)return i;const t=w();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),y(new WebAssembly.Instance(e,t),e)}},t)}();const o=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r](i,i.exports,n),i.loaded=!0,i.exports}function r(e){return e?e.slice(0):void 0}function o(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function i(e){if("string"!=typeof e)return;const t=e.trim();return 0!==t.length?t:void 0}function a(e){return"deepfilternet"===e?"deepfilternet":"rnnoise"}function s(e){return!Number.isFinite(e)||(e??0)<=0?1e3:e??1e3}function l(e){return Number.isFinite(e)?Math.max(0,e??0):0}function c(e){return{vadLogs:Boolean(e?.vadLogs),bufferOverflowMs:s(e?.bufferOverflowMs)}}function d(e,t){return t?{vadLogs:t.vadLogs??e.vadLogs,bufferOverflowMs:void 0!==t.bufferOverflowMs?s(t.bufferOverflowMs):e.bufferOverflowMs}:{...e}}function u(e,t){if(!t)return{...e,modelBytes:r(e.modelBytes)};let n=i(e.modelUrl),o=r(e.modelBytes);if(!0===t.clearModel&&(n=void 0,o=void 0),void 0!==t.modelUrl&&(n=i(t.modelUrl),o=void 0),void 0!==t.modelBuffer){if(t.modelBuffer.byteLength<=0)throw new Error("DeepFilter modelBuffer is empty");o=new Uint8Array(t.modelBuffer.slice(0))}return{modelUrl:n,modelBytes:o,attenLimDb:void 0!==t.attenLimDb?(a=t.attenLimDb,Number.isFinite(a)?Math.abs(a??100):100):e.attenLimDb,postFilterBeta:void 0!==t.postFilterBeta?l(t.postFilterBeta):e.postFilterBeta};var a}n.m=e,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.b=self.location+"";class f{_config;constructor(e){this._config=e}}class _ extends f{}let m,p=!1;function g(e){p||(m=n(807).A,m.initSync(e),p=!0)}class b extends _{moduleId="deepfilternet";_bindings;_state=0;_frameLength=0;_lookahead=0;_disposed=!1;constructor(e,t){if(super({...e,modelBytes:r(e.modelBytes)}),t&&g(t),!m)throw new Error("DeepFilter WASM not initialized. Provide deepfilterWasm in INIT_PIPELINE.");this._bindings=m,this._createState(this._config)}get frameLength(){return this._frameLength}get lookahead(){return this._lookahead}processFrame(e,t){const n=this._bindings.df_process_frame(this._state,e);if(n.length!==this._frameLength)throw new Error(`DeepFilterNet returned invalid frame size. expected=${this._frameLength}, actual=${n.length}`);t.set(n)}updateConfig(e){const t={...e,modelBytes:r(e.modelBytes)},n=!o(this._config.modelBytes,t.modelBytes);this._config=t,n?this._createState(t):(this._bindings.df_set_atten_lim(this._state,t.attenLimDb),this._bindings.df_set_post_filter_beta(this._state,t.postFilterBeta))}dispose(){this._disposed||(this._disposed=!0,this._state&&(this._bindings.df_destroy(this._state),this._state=0))}_createState(e){this._state&&(this._bindings.df_destroy(this._state),this._state=0);const t=r(e.modelBytes);if(this._state=t?this._bindings.df_create(t,e.attenLimDb):this._bindings.df_create_default(e.attenLimDb),!this._state)throw new Error("Failed to create DeepFilterNet state");const n=this._bindings.df_get_frame_length(this._state);if(!Number.isFinite(n)||n<=0)throw this._bindings.df_destroy(this._state),this._state=0,new Error(`Invalid DeepFilterNet frame length: ${n}`);this._frameLength=n,this._lookahead=this._bindings.df_get_lookahead(this._state),this._bindings.df_set_atten_lim(this._state,e.attenLimDb),this._bindings.df_set_post_filter_beta(this._state,e.postFilterBeta)}}var h,w,y=(h="file:///Users/luke/workspace/project/denoise-plugin/js/src/dist/rnnoise-sync.js",function(e={}){var t,r,o,i,a=e,s=(new Promise(((e,t)=>{r=e,o=t})),"object"==typeof window),l="undefined"!=typeof WorkerGlobalScope,c="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&"renderer"!=process.type,d=!s&&!c&&!l,u=Object.assign({},a),f="";if(d){if("object"==typeof process||"object"==typeof window||"undefined"!=typeof WorkerGlobalScope)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");i=e=>{if("function"==typeof readbuffer)return new Uint8Array(readbuffer(e));let t=read(e,"binary");return v("object"==typeof t),t},globalThis.clearTimeout??=e=>{},globalThis.setTimeout??=e=>e(),globalThis.arguments||globalThis.scriptArgs,"undefined"!=typeof print&&(globalThis.console??={},console.log=print,console.warn=console.error=globalThis.printErr??print)}else{if(!s&&!l)throw new Error("environment detection error");if(l?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),h&&(f=h),f=f.startsWith("blob:")?"":f.slice(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1),"object"!=typeof window&&"undefined"==typeof WorkerGlobalScope)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");l&&(i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})}var _,m=a.print||console.log.bind(console),p=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,_="fetchSettings",Object.getOwnPropertyDescriptor(a,_)&&N(`\`Module.${_}\` was supplied but \`${_}\` not included in INCOMING_MODULE_JS_API`),a.arguments&&a.arguments,F("arguments","arguments_"),a.thisProgram&&a.thisProgram,F("thisProgram","thisProgram"),v(void 0===a.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),v(void 0===a.read,"Module.read option was removed"),v(void 0===a.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),v(void 0===a.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),v(void 0===a.setWindowTitle,"Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),v(void 0===a.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),F("asm","wasmExports"),F("readAsync","readAsync"),F("readBinary","readBinary"),F("setWindowTitle","setWindowTitle"),v(!c,"node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.");var g,b=a.wasmBinary;F("wasmBinary","wasmBinary"),"object"!=typeof WebAssembly&&p("no native wasm support detected");var w,y,E=!1;function v(e,t){e||N("Assertion failed"+(t?": "+t:""))}var T=!1;function S(){if(!E){var e=ee();0==e&&(e+=4);var t=y[e>>>2>>>0],n=y[e+4>>>2>>>0];34821223==t&&2310721022==n||N(`Stack overflow! Stack cookie has been overwritten at ${H(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${H(n)} ${H(t)}`),1668509029!=y[0]&&N("Runtime error: The application has corrupted its heap memory area (address zero)!")}}if((()=>{var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})(),a.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");function F(e,t,n=!0){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,get(){N(`\`Module.${e}\` has been replaced by \`${t}\``+(n?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":""))}})}function A(e){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,set(){N(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function L(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}function I(e,t){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get(){t()}})}function M(e,t){I(e,(()=>{z(`\`${e}\` is not longer defined by emscripten. ${t}`)}))}function R(e){Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{configurable:!0,get(){var t=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;L(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),N(t)}})}function O(){var e=g.buffer;a.HEAP8=new Int8Array(e),a.HEAP16=new Int16Array(e),a.HEAPU8=w=new Uint8Array(e),a.HEAPU16=new Uint16Array(e),a.HEAP32=new Int32Array(e),a.HEAPU32=y=new Uint32Array(e),a.HEAPF32=new Float32Array(e),a.HEAPF64=new Float64Array(e),a.HEAP64=new BigInt64Array(e),a.HEAPU64=new BigUint64Array(e)}M("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),M("asm","Please use wasmExports instead"),v(!a.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),v("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),v(!a.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),v(!a.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");var P=0,C=null,k={},D=null;function N(e){a.onAbort?.(e),p(e="Aborted("+e+")"),E=!0;var t=new WebAssembly.RuntimeError(e);throw o(t),t}var U,x={error(){N("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init(){x.error()},createDataFile(){x.error()},createPreloadedFile(){x.error()},createLazyFile(){x.error()},open(){x.error()},mkdev(){x.error()},registerDevice(){x.error()},analyzePath(){x.error()},ErrnoError(){x.error()}};function B(e,t){return(...n)=>{v(T,`native function \`${e}\` called before runtime initialization`);var r=Z[e];return v(r,`exported native function \`${e}\` not found`),v(n.length<=t,`native function \`${e}\` called with ${n.length} args but expects ${t}`),r(...n)}}a.FS_createDataFile=x.createDataFile,a.FS_createPreloadedFile=x.createPreloadedFile;var W=e=>{for(;e.length>0;)e.shift()(a)},j=[],G=[];a.noExitRuntime;var $,H=e=>(v("number"==typeof e),"0x"+e.toString(16).padStart(8,"0")),z=e=>{z.shown||={},z.shown[e]||(z.shown[e]=1,p(e))},Y="undefined"!=typeof TextDecoder?new TextDecoder:void 0,V=(e,t=0,n=NaN)=>{for(var r=(t>>>=0)+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.buffer&&Y)return Y.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if(224==(240&a)?a=(15&a)<<12|s<<6|l:(240!=(248&a)&&z("Invalid UTF-8 leading byte "+H(a)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),a=(7&a)<<18|s<<12|l<<6|63&e[t++]),a<65536)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},J=(e,t)=>(v("number"==typeof e,`UTF8ToString expects a number (got ${typeof e})`),(e>>>=0)?V(w,e,t):""),K=e=>{var t=g.buffer,n=(e-t.byteLength+65535)/65536|0;try{return g.grow(n),O(),1}catch(n){p(`growMemory: Attempted to grow heap from ${t.byteLength} bytes to ${e} bytes, but got error: ${n}`)}},q=[null,[],[]],X={__assert_fail:function(e,t,n,r){return t>>>=0,r>>>=0,N(`Assertion failed: ${J(e>>>=0)}, at: `+[t?J(t):"unknown filename",n,r?J(r):"unknown function"])},emscripten_resize_heap:function(e){e>>>=0;var t=w.length;v(e>t);var n,r=4294901760;if(e>r)return p(`Cannot enlarge memory, requested ${e} bytes, but the limit is 4294901760 bytes!`),!1;for(var o=1;o<=4;o*=2){var i=t*(1+.2/o);i=Math.min(i,e+100663296);var a=Math.min(r,(n=Math.max(e,i),v(65536,"alignment argument is required"),65536*Math.ceil(n/65536)));if(K(a))return!0}return p(`Failed to grow the heap from ${t} bytes to ${a} bytes, not enough memory!`),!1},fd_write:function(e,t,n,r){t>>>=0,n>>>=0,r>>>=0;for(var o=0,i=0;i<n;i++){var a=y[t>>>2>>>0],s=y[t+4>>>2>>>0];t+=8;for(var l=0;l<s;l++)c=e,d=w[a+l>>>0],u=void 0,v(u=q[c]),0===d||10===d?((1===c?m:p)(V(u)),u.length=0):u.push(d);o+=s}var c,d,u;return y[r>>>2>>>0]=o,0}},Z=function(){function e(e,t){return Z=function(e){var t,n=e=>t=>e(t)>>>0,r=e=>()=>e()>>>0;return(e=Object.assign({},e)).malloc=n(e.malloc),e.strerror=(t=e.strerror,e=>t(e)>>>0),e.emscripten_stack_get_base=r(e.emscripten_stack_get_base),e.emscripten_stack_get_end=r(e.emscripten_stack_get_end),e._emscripten_stack_alloc=n(e._emscripten_stack_alloc),e.emscripten_stack_get_current=r(e.emscripten_stack_get_current),e}(Z=e.exports),v(g=Z.memory,"memory not found in wasm exports"),O(),function(e){if(P--,a.monitorRunDependencies?.(P),e?(v(k[e]),delete k[e]):p("warning: run dependency removed without ID"),0==P&&(null!==D&&(clearInterval(D),D=null),C)){var t=C;C=null,t()}}("wasm-instantiate"),Z}var t;t="wasm-instantiate",P++,a.monitorRunDependencies?.(P),t?(v(!k[t]),k[t]=1,null===D&&"undefined"!=typeof setInterval&&(D=setInterval((()=>{if(E)return clearInterval(D),void(D=null);var e=!1;for(var t in k)e||(e=!0,p("still waiting on run dependencies:")),p(`dependency: ${t}`);e&&p("(end of list)")}),1e4))):p("warning: run dependency added without ID");var r,o={env:X,wasi_snapshot_preview1:X};return a.instantiateWasm?new Promise(((t,n)=>{try{a.instantiateWasm(o,((n,r)=>{e(n),t(n.exports)}))}catch(e){p(`Module.instantiateWasm callback failed with error: ${e}`),n(e)}})):(U??=a.locateFile?(r="rnnoise-sync.wasm",a.locateFile?a.locateFile(r,f):f+r):d?"rnnoise-sync.wasm":new URL(Object(function(){var e=new Error("Cannot find module 'rnnoise-sync.wasm'");throw e.code="MODULE_NOT_FOUND",e}()),n.b).href,e(function(e,t){var n,r=function(e){if(e==U&&b)return new Uint8Array(b);if(i)return i(e);throw'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)'}(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}(U,o)[0]))}(),Q=(B("__wasm_call_ctors",0),a._malloc=B("malloc",1),a._free=B("free",1),a._rnnoise_init=B("rnnoise_init",2),a._rnnoise_create=B("rnnoise_create",1),a._rnnoise_destroy=B("rnnoise_destroy",1),a._rnnoise_process_frame=B("rnnoise_process_frame",3),B("fflush",1),B("strerror",1),Z.emscripten_stack_init),ee=(Z.emscripten_stack_get_free,Z.emscripten_stack_get_base,Z.emscripten_stack_get_end);if(Z._emscripten_stack_restore,Z._emscripten_stack_alloc,Z.emscripten_stack_get_current,["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","stackAlloc","getTempRet0","setTempRet0","zeroMemory","exitJS","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","emscriptenLog","readEmAsmArgs","jstoi_q","getExecutableName","listenOnce","autoResumeAudioContext","getDynCaller","dynCall","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","asyncLoad","mmapAlloc","HandleAllocator","getNativeTypeSize","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","getEnvStrings","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","initRandomFill","randomFill","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","ExceptionInfo","findMatchingCatch","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar","FS_unlink","FS_createDataFile","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","setErrNo","demangle","stackTrace"].forEach((function(e){I(e,(()=>{var t=`\`${e}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,n=e;n.startsWith("_")||(n="$"+e),t+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${n}')`,L(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),z(t)})),R(e)})),["run","addRunDependency","removeRunDependency","out","err","callMain","abort","wasmMemory","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","stackSave","stackRestore","ptrToString","getHeapMax","growMemory","ENV","ERRNO_CODES","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","jstoi_s","alignMemory","wasmTable","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","UTF16Decoder","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","flush_NO_FILESYSTEM","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","Browser","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","preloadPlugins","FS_stdin_getChar_buffer","FS_createPath","FS_createDevice","FS_readFile","FS","FS_createLazyFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack","print","printErr"].forEach(R),a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();A("preInit"),function e(){function t(){v(!$),$=!0,a.calledRun=!0,E||(v(!T),T=!0,S(),Z.__wasm_call_ctors(),r(a),a.onRuntimeInitialized?.(),A("onRuntimeInitialized"),v(!a._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(S(),a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)e=a.postRun.shift(),j.unshift(e);var e;A("postRun"),W(j)}())}var n;P>0?C=e:(Q(),v(!(3&(n=ee()))),0==n&&(n+=4),y[n>>>2>>>0]=34821223,y[n+4>>>2>>>0]=2310721022,y[0]=1668509029,function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)e=a.preRun.shift(),G.unshift(e);var e;A("preRun"),W(G)}(),P>0?C=e:(a.setStatus?(a.setStatus("Running..."),setTimeout((()=>{setTimeout((()=>a.setStatus("")),1),t()}),1)):t(),S()))}(),t=a;for(const t of Object.keys(a))t in e||Object.defineProperty(e,t,{configurable:!0,get(){N(`Access to module property ('${t}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return t});w=y;const E=y=function(e){if(new.target)throw new Error("createRNNWasmModuleSync() should not be called with `new createRNNWasmModuleSync()`");return w(e)},v=480;class T extends _{moduleId="rnnoise";frameLength=v;_module;_context;_inputPtr;_outputPtr;_inputHeap;_outputHeap;_disposed=!1;constructor(e,t){if(super(e),this._module=E(t?{wasmBinary:t,locateFile:()=>"rnnoise-sync.wasm"}:{}),this._context=this._module._rnnoise_create(),!this._context)throw new Error("Failed to initialize RNNoise context");if(this._inputPtr=this._module._malloc(v*Float32Array.BYTES_PER_ELEMENT),this._outputPtr=this._module._malloc(v*Float32Array.BYTES_PER_ELEMENT),!this._inputPtr||!this._outputPtr)throw this._inputPtr&&this._module._free(this._inputPtr),this._outputPtr&&this._module._free(this._outputPtr),this._module._rnnoise_destroy(this._context),new Error("Failed to allocate RNNoise heap buffers");const n=this._inputPtr>>2,r=this._outputPtr>>2;this._inputHeap=this._module.HEAPF32.subarray(n,n+v),this._outputHeap=this._module.HEAPF32.subarray(r,r+v)}processFrame(e,t){for(let t=0;t<v;t+=1)this._inputHeap[t]=32768*e[t];const n=this._module._rnnoise_process_frame(this._context,this._outputPtr,this._inputPtr),r=1/32768;for(let e=0;e<v;e+=1)t[e]=this._outputHeap[e]*r;return n}updateConfig(e){this._config={...e}}dispose(){this._disposed||(this._disposed=!0,this._module._rnnoise_destroy(this._context),this._module._free(this._inputPtr),this._module._free(this._outputPtr))}}let S,F,A,L,I,M,R=!1,O="rnnoise",P=!0,C=c(),k={modelUrl:void 0,modelBytes:void 0,attenLimDb:100,postFilterBeta:0};const D="[AudioPipeline:Worker]";function N(e,t){R&&S?.postMessage({type:"LOG",level:"info",tag:D,text:e,data:t})}function U(e,t){S?.postMessage(e,t??[])}function x(e){const t=e instanceof Error?e.message:String(e);var n;n=t,S?.postMessage({type:"LOG",level:"error",tag:D,text:n,data:undefined}),U({type:"ERROR",error:t})}function B(e){return e&&e.byteLength>0?e.slice(0):void 0}function W(){return"deepfilternet"===O?M:I}function j(e){O=e;const t=W();return N(`MODULE_ACTIVE:${e}`,{frameLength:t.frameLength}),{frameLength:t.frameLength,lookahead:t instanceof b?t.lookahead:0}}function G(){if(!M)return;const e=!o(L,k.modelBytes);M.updateConfig(k),e&&(L=r(k.modelBytes),"deepfilternet"===O&&U({type:"MODULE_CHANGED",frameLength:M.frameLength,lookahead:M.lookahead}))}function $(e){const t=e.data;if(t?.type)try{switch(t.type){case"INIT":!function(e){const t=performance.now();var n;R=e.debugLogs??!1,O=a(e.moduleId),(n=e.wasmBinaries)&&(n.rnnoiseWasm&&(F=n.rnnoiseWasm.slice(0)),n.deepfilterWasm&&(A=n.deepfilterWasm.slice(0),g(n.deepfilterWasm))),C=d(c(),e.moduleConfigs?.rnnoise),k=u({modelUrl:void 0,modelBytes:void 0,attenLimDb:100,postFilterBeta:0},e.moduleConfigs?.deepfilternet),function(){const e=performance.now();I||(I=new T(C,B(F)),N("PRE_INIT rnnoise",{elapsed:`${(performance.now()-e).toFixed(2)}ms`}));const t=performance.now();M||(M=new b(k,B(A)),L=r(k.modelBytes),N("PRE_INIT deepfilternet",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})),N("PRE_INIT all modules done",{totalElapsed:`${(performance.now()-e).toFixed(2)}ms`})}();const o=j(O);U({type:"INIT_OK",frameLength:o.frameLength,lookahead:o.lookahead}),N("WORKER_READY",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})}(t);break;case"PROCESS_FRAME":!function(e){const t=e.inputBuffer,n=W();if(!P||!n){const e=new Float32Array(t.length);return e.set(t),void U({type:"FRAME_RESULT",outputBuffer:e},[e.buffer])}if(t.length<n.frameLength)x(`Input buffer too small: ${t.length} < ${n.frameLength}`);else try{const e=new Float32Array(n.frameLength);U({type:"FRAME_RESULT",outputBuffer:e,vadScore:n.processFrame(t,e)},[e.buffer])}catch(e){x(e)}}(t);break;case"SET_MODULE":!function(e){const t=performance.now(),n=a(e.moduleId);if(e.config?.rnnoise&&(C=d(C,e.config.rnnoise),I?.updateConfig(C)),e.config?.deepfilternet&&(k=u(k,e.config.deepfilternet),M&&G()),n===O)return void N("SET_MODULE (same module, config only)",{moduleId:n,elapsed:`${(performance.now()-t).toFixed(2)}ms`});const r=j(n);N("SET_MODULE (switch)",{to:n,elapsed:`${(performance.now()-t).toFixed(2)}ms`}),U({type:"MODULE_CHANGED",frameLength:r.frameLength,lookahead:r.lookahead})}(t);break;case"SET_CONFIG":!function(e){const t=performance.now();if("rnnoise"===e.moduleId)return C=d(C,e.config),I?.updateConfig(C),void N("SET_CONFIG rnnoise",{elapsed:`${(performance.now()-t).toFixed(2)}ms`});k=u(k,e.config),M&&G(),N("SET_CONFIG deepfilternet",{elapsed:`${(performance.now()-t).toFixed(2)}ms`})}(t);break;case"SET_ENABLED":P=t.enable,N(t.enable?"PROCESSING_ENABLED":"PROCESSING_DISABLED");break;case"DESTROY":I?.dispose(),M?.dispose(),I=void 0,M=void 0,N("WORKER_DESTROYED")}}catch(e){x(e)}}globalThis.onmessage=e=>{const t=e.data;if("CONNECT_PORT"===t?.type)return S=t.port,S.onmessage=$,void N("WORKER_PORT_CONNECTED");"SET_DEBUG"!==t?.type||(R=Boolean(t.debugLogs))}})();
@@ -1 +1 @@
1
- "undefined"==typeof self&&(globalThis.self=globalThis),(()=>{"use strict";function e(e){return"deepfilternet"===e?"deepfilternet":"rnnoise"}class t{_data;_readIndex=0;_writeIndex=0;_framesAvailable=0;constructor(e){this._data=new Float32Array(e)}get framesAvailable(){return this._framesAvailable}get capacity(){return this._data.length}push(e){const t=this._data.length,s=e.length;if(0===s)return;const r=t-this._writeIndex;s<=r?this._data.set(e,this._writeIndex):(this._data.set(e.subarray(0,r),this._writeIndex),this._data.set(e.subarray(r),0)),this._writeIndex=(this._writeIndex+s)%t,this._framesAvailable=Math.min(this._framesAvailable+s,t)}pull(e){const t=e.length;if(this._framesAvailable<t)return!1;const s=this._data.length,r=s-this._readIndex;return t<=r?e.set(this._data.subarray(this._readIndex,this._readIndex+t)):(e.set(this._data.subarray(this._readIndex,s)),e.set(this._data.subarray(0,t-r),r)),this._readIndex=(this._readIndex+t)%s,this._framesAvailable-=t,!0}drainInto(e){const t=this._framesAvailable;if(0===t)return;const s=this._data.length,r=s-this._readIndex;t<=r?e.push(this._data.subarray(this._readIndex,this._readIndex+t)):(e.push(this._data.subarray(this._readIndex,s)),e.push(this._data.subarray(0,t-r))),this._readIndex=(this._readIndex+t)%s,this._framesAvailable=0}clear(){this._readIndex=0,this._writeIndex=0,this._framesAvailable=0,this._data.fill(0)}}class s{_pool=[];_frameSize;constructor(e,t=8){this._frameSize=e;for(let s=0;s<t;s++)this._pool.push(new Float32Array(e))}acquire(){return this._pool.pop()??new Float32Array(this._frameSize)}release(e){e.length===this._frameSize&&0!==e.buffer.byteLength&&this._pool.push(e)}resize(e){return e===this._frameSize?this:new s(e,this._pool.length||8)}}class r extends AudioWorkletProcessor{_messageChain=Promise.resolve();_debugLogs=!1;_destroyed=!1;_shouldProcess=!0;_workerReady=!1;_switchingModule=!1;_currentModuleId="rnnoise";_frameLength=480;_transferSize=480;_prefilled=!1;_workerPort;_inputQueue=new t(30720);_outputQueue=new t(30720);_inputPool=new s(480,8);_lastVadScore;_lastVadLogAtMs=0;_vadLogIntervalMs=1e3;_vadLogsEnabled=!1;constructor(e){super(),this._debugLogs=e.processorOptions?.debugLogs??!1,this._setupMessageHandler(),this._logInfo("AUDIO_PIPELINE_WORKLET_INIT")}process(e,t){if(this._destroyed)return!1;if(this._switchingModule)return!0;const s=e[0]?.[0],r=t[0]?.[0];if(!s||!r)return!0;this._inputQueue.push(s);const i=this._workerReady&&this._workerPort;for(;this._inputQueue.framesAvailable>=this._transferSize;){const e=this._inputPool.acquire();this._inputQueue.pull(e),i?this._workerPort.postMessage({type:"PROCESS_FRAME",inputBuffer:e},[e.buffer]):this._outputQueue.push(e)}this._outputQueue.pull(r);const o=t[0];for(let e=1;e<o.length;e++)o[e].set(r);return!0}_setupMessageHandler(){this.port.onmessage=e=>{const t=e.data;this._messageChain=this._messageChain.then((()=>this._dispatch(t))).catch((e=>{this._respondError(t?.requestId,t?.message??"UNKNOWN",e)}))}}async _dispatch(e){if(!e?.message)return;const t=this._nowMs();switch(e.message){case"INIT_PIPELINE":this._initPipeline(e);break;case"SET_ENABLED":this._setEnabled(e.enable);break;case"SET_STAGE_MODULE":this._handleSetStageModule(e);break;case"SET_MODULE_CONFIG":this._handleSetModuleConfig(e);break;case"DESTROY":this._destroy();break;default:throw new Error(`Unknown command: ${String(e.message)}`)}this._logInfo(`${e.message} dispatch`,{elapsed:`${(this._nowMs()-t).toFixed(2)}ms`}),this._respondOk(e.requestId,e.message)}_initPipeline(t){if(this._debugLogs=t.debugLogs??this._debugLogs,this._currentModuleId=e(t.stages?.denoise),this._shouldProcess=t.enable??this._shouldProcess,this._vadLogIntervalMs=t.moduleConfigs?.rnnoise?.bufferOverflowMs??1e3,this._vadLogsEnabled=t.moduleConfigs?.rnnoise?.vadLogs??!1,t.workerPort){this._workerPort=t.workerPort,this._setupWorkerPort();const e=t.frameLength??480;this._onWorkerInitOk(e)}this._logInfo(`AUDIO_PIPELINE_WORKLET_READY:${this._currentModuleId}`)}_setupWorkerPort(){this._workerPort&&(this._workerPort.onmessage=e=>{const t=e.data;if(t?.type)switch(t.type){case"INIT_OK":this._onWorkerInitOk(t.frameLength);break;case"FRAME_RESULT":this._onFrameResult(t.outputBuffer,t.vadScore);break;case"MODULE_CHANGED":this._onModuleChanged(t.frameLength,t.lookahead);break;case"ERROR":this._logError(`WORKER_ERROR:${t.error}`);break;case"LOG":this._forwardLog(t.level,t.tag,t.text,t.data)}})}_onWorkerInitOk(e){this._frameLength=e,this._rebuildForFrameLength(e),this._workerReady=!0,this._logInfo("WORKER_INIT_OK",{frameLength:e})}_onFrameResult(e,t){this._outputQueue.push(e),this._maybeEmitVadLog(t)}_onModuleChanged(e,t){const s=this._switchingModule;this._switchingModule=!1,e!==this._frameLength&&(this._frameLength=e,this._rebuildForFrameLength(e)),this._logInfo("MODULE_CHANGED",{frameLength:e,resumed:s})}_rebuildForFrameLength(e){this._transferSize=1*e;const s=64*Math.max(this._transferSize,128),r=this._inputQueue,i=this._outputQueue;if(this._inputQueue=new t(s),this._outputQueue=new t(s),r.drainInto(this._inputQueue),i.drainInto(this._outputQueue),!this._prefilled){this._prefilled=!0;const t=128*Math.ceil(2*e/128);this._outputQueue.push(new Float32Array(t)),this._logInfo("PREFILL",{frameLength:e,prefill:t,framesPerTransfer:1})}this._inputPool=this._inputPool.resize(this._transferSize),this._logInfo("REBUILD_QUEUES",{frameLength:e,transferSize:this._transferSize,queueCapacity:s})}_setEnabled(e){this._shouldProcess=e,this._lastVadLogAtMs=0,this._workerPort?.postMessage({type:"SET_ENABLED",enable:e}),this._logInfo(e?"AUDIO_PIPELINE_ENABLED":"AUDIO_PIPELINE_DISABLED")}_handleSetStageModule(t){if("denoise"!==t.stage)throw new Error(`Unsupported stage: ${t.stage}`);const s=e(t.moduleId);this._currentModuleId=s,this._switchingModule=!0,this._logInfo("MODULE_SWITCH_START",{from:this._currentModuleId,to:s}),this._workerPort?.postMessage({type:"SET_MODULE",moduleId:s,config:t.config?{["rnnoise"===s?"rnnoise":"deepfilternet"]:t.config}:void 0})}_handleSetModuleConfig(e){if("rnnoise"===e.moduleId){const t=e.config;t?.bufferOverflowMs&&(this._vadLogIntervalMs=t.bufferOverflowMs)}this._workerPort?.postMessage({type:"SET_CONFIG",moduleId:e.moduleId,config:e.config})}_destroy(){this._destroyed||(this._destroyed=!0,this._workerReady=!1,this._workerPort?.postMessage({type:"DESTROY"}),this._workerPort?.close(),this._workerPort=void 0,this._inputQueue.clear(),this._outputQueue.clear(),this._logInfo("AUDIO_PIPELINE_WORKLET_DESTROYED"))}_respondOk(e,t){if(void 0===e)return;const s={message:"COMMAND_OK",requestId:e,command:t};this.port.postMessage(s)}_respondError(e,t,s){const r=s instanceof Error?s.message:String(s),i={message:"COMMAND_ERROR",requestId:e,command:t,error:r};this.port.postMessage(i),this._logError(`${t}:${r}`)}_maybeEmitVadLog(e){if(!this._debugLogs||"rnnoise"!==this._currentModuleId||!this._vadLogsEnabled)return;if(!Number.isFinite(e))return;this._lastVadScore=e;const t=this._nowMs();t-this._lastVadLogAtMs<this._vadLogIntervalMs||(this._lastVadLogAtMs=t,this._logInfo("AUDIO_PIPELINE_RNNOISE_VAD",{vadScore:this._lastVadScore,intervalMs:this._vadLogIntervalMs}))}_nowMs(){return"function"==typeof globalThis.performance?.now?globalThis.performance.now():Date.now()}static _LOG_TAG="[AudioPipeline:Worklet]";_postLog(e,t,s,r){const i={message:"LOG",level:e,tag:t,text:s,data:r};try{this.port.postMessage(i)}catch{}}_forwardLog(e,t,s,r){this._postLog(e,t,s,r)}_logInfo(e,t,s=!1){(s||this._debugLogs)&&this._postLog("info",r._LOG_TAG,e,t)}_logError(e,t){this._postLog("error",r._LOG_TAG,e,t)}}registerProcessor("AudioPipelineWorklet",r)})();
1
+ "undefined"==typeof self&&(globalThis.self=globalThis),(()=>{"use strict";function e(e){return"deepfilternet"===e?"deepfilternet":"rnnoise"}class t{_data;_readIndex=0;_writeIndex=0;_framesAvailable=0;constructor(e){this._data=new Float32Array(e)}get framesAvailable(){return this._framesAvailable}get capacity(){return this._data.length}push(e){const t=this._data.length,s=e.length;if(0===s)return;const r=t-this._writeIndex;s<=r?this._data.set(e,this._writeIndex):(this._data.set(e.subarray(0,r),this._writeIndex),this._data.set(e.subarray(r),0)),this._writeIndex=(this._writeIndex+s)%t,this._framesAvailable=Math.min(this._framesAvailable+s,t)}pull(e){const t=e.length;if(this._framesAvailable<t)return!1;const s=this._data.length,r=s-this._readIndex;return t<=r?e.set(this._data.subarray(this._readIndex,this._readIndex+t)):(e.set(this._data.subarray(this._readIndex,s)),e.set(this._data.subarray(0,t-r),r)),this._readIndex=(this._readIndex+t)%s,this._framesAvailable-=t,!0}drainInto(e){const t=this._framesAvailable;if(0===t)return;const s=this._data.length,r=s-this._readIndex;t<=r?e.push(this._data.subarray(this._readIndex,this._readIndex+t)):(e.push(this._data.subarray(this._readIndex,s)),e.push(this._data.subarray(0,t-r))),this._readIndex=(this._readIndex+t)%s,this._framesAvailable=0}clear(){this._readIndex=0,this._writeIndex=0,this._framesAvailable=0,this._data.fill(0)}}class s extends AudioWorkletProcessor{_messageChain=Promise.resolve();_debugLogs=!1;_destroyed=!1;_shouldProcess=!0;_workerReady=!1;_currentModuleId="rnnoise";_frameLength=480;_prefilled=!1;_workerPort;_inputQueue=new t(30720);_outputQueue=new t(30720);_lastVadScore;_lastVadLogAtMs=0;_vadLogIntervalMs=1e3;_vadLogsEnabled=!1;constructor(e){super(),this._debugLogs=e.processorOptions?.debugLogs??!1,this._setupMessageHandler(),this._logInfo("AUDIO_PIPELINE_WORKLET_INIT")}process(e,t){if(this._destroyed)return!1;const s=e[0]?.[0],r=t[0]?.[0];if(!s||!r)return!0;this._inputQueue.push(s);const o=this._workerReady&&this._workerPort;for(;this._inputQueue.framesAvailable>=this._frameLength;){const e=new Float32Array(this._frameLength);this._inputQueue.pull(e),o?this._workerPort.postMessage({type:"PROCESS_FRAME",inputBuffer:e},[e.buffer]):this._outputQueue.push(e)}this._outputQueue.pull(r);const i=t[0];for(let e=1;e<i.length;e++)i[e].set(r);return!0}_setupMessageHandler(){this.port.onmessage=e=>{const t=e.data;this._messageChain=this._messageChain.then((()=>this._dispatch(t))).catch((e=>{this._respondError(t?.requestId,t?.message??"UNKNOWN",e)}))}}async _dispatch(e){if(!e?.message)return;const t=this._nowMs();switch(e.message){case"INIT_PIPELINE":this._initPipeline(e);break;case"SET_ENABLED":this._setEnabled(e.enable);break;case"SET_STAGE_MODULE":this._handleSetStageModule(e);break;case"SET_MODULE_CONFIG":this._handleSetModuleConfig(e);break;case"DESTROY":this._destroy();break;default:throw new Error(`Unknown command: ${String(e.message)}`)}this._logInfo(`${e.message} dispatch`,{elapsed:`${(this._nowMs()-t).toFixed(2)}ms`}),this._respondOk(e.requestId,e.message)}_initPipeline(t){if(this._debugLogs=t.debugLogs??this._debugLogs,this._currentModuleId=e(t.stages?.denoise),this._shouldProcess=t.enable??this._shouldProcess,this._vadLogIntervalMs=t.moduleConfigs?.rnnoise?.bufferOverflowMs??1e3,this._vadLogsEnabled=t.moduleConfigs?.rnnoise?.vadLogs??!1,t.workerPort){this._workerPort=t.workerPort,this._setupWorkerPort();const e=t.frameLength??480;this._onWorkerInitOk(e)}this._logInfo(`AUDIO_PIPELINE_WORKLET_READY:${this._currentModuleId}`)}_setupWorkerPort(){this._workerPort&&(this._workerPort.onmessage=e=>{const t=e.data;if(t?.type)switch(t.type){case"INIT_OK":this._onWorkerInitOk(t.frameLength);break;case"FRAME_RESULT":this._onFrameResult(t.outputBuffer,t.vadScore);break;case"MODULE_CHANGED":this._onModuleChanged(t.frameLength,t.lookahead);break;case"ERROR":this._logError(`WORKER_ERROR:${t.error}`);break;case"LOG":this._forwardLog(t.level,t.tag,t.text,t.data)}})}_onWorkerInitOk(e){this._frameLength=e,this._rebuildForFrameLength(e),this._workerReady=!0,this._logInfo("WORKER_INIT_OK",{frameLength:e})}_onFrameResult(e,t){this._outputQueue.push(e),this._maybeEmitVadLog(t)}_onModuleChanged(e,t){e!==this._frameLength&&(this._frameLength=e,this._rebuildForFrameLength(e)),this._logInfo("MODULE_CHANGED",{frameLength:e})}_rebuildForFrameLength(e){const s=64*Math.max(e,128),r=this._inputQueue,o=this._outputQueue;if(this._inputQueue=new t(s),this._outputQueue=new t(s),r.drainInto(this._inputQueue),o.drainInto(this._outputQueue),!this._prefilled){this._prefilled=!0;const t=128*Math.ceil(2*e/128);this._outputQueue.push(new Float32Array(t)),this._logInfo("PREFILL",{frameLength:e,prefill:t})}this._logInfo("REBUILD_QUEUES",{frameLength:e,queueCapacity:s})}_setEnabled(e){this._shouldProcess=e,this._lastVadLogAtMs=0,this._workerPort?.postMessage({type:"SET_ENABLED",enable:e}),this._logInfo(e?"AUDIO_PIPELINE_ENABLED":"AUDIO_PIPELINE_DISABLED")}_handleSetStageModule(t){if("denoise"!==t.stage)throw new Error(`Unsupported stage: ${t.stage}`);const s=e(t.moduleId);this._currentModuleId=s,this._logInfo("MODULE_SWITCH_START",{from:this._currentModuleId,to:s}),this._workerPort?.postMessage({type:"SET_MODULE",moduleId:s,config:t.config?{["rnnoise"===s?"rnnoise":"deepfilternet"]:t.config}:void 0})}_handleSetModuleConfig(e){if("rnnoise"===e.moduleId){const t=e.config;t?.bufferOverflowMs&&(this._vadLogIntervalMs=t.bufferOverflowMs)}this._workerPort?.postMessage({type:"SET_CONFIG",moduleId:e.moduleId,config:e.config})}_destroy(){this._destroyed||(this._destroyed=!0,this._workerReady=!1,this._workerPort?.postMessage({type:"DESTROY"}),this._workerPort?.close(),this._workerPort=void 0,this._inputQueue.clear(),this._outputQueue.clear(),this._logInfo("AUDIO_PIPELINE_WORKLET_DESTROYED"))}_respondOk(e,t){if(void 0===e)return;const s={message:"COMMAND_OK",requestId:e,command:t};this.port.postMessage(s)}_respondError(e,t,s){const r=s instanceof Error?s.message:String(s),o={message:"COMMAND_ERROR",requestId:e,command:t,error:r};this.port.postMessage(o),this._logError(`${t}:${r}`)}_maybeEmitVadLog(e){if(!this._debugLogs||"rnnoise"!==this._currentModuleId||!this._vadLogsEnabled)return;if(!Number.isFinite(e))return;this._lastVadScore=e;const t=this._nowMs();t-this._lastVadLogAtMs<this._vadLogIntervalMs||(this._lastVadLogAtMs=t,this._logInfo("AUDIO_PIPELINE_RNNOISE_VAD",{vadScore:this._lastVadScore,intervalMs:this._vadLogIntervalMs}))}_nowMs(){return"function"==typeof globalThis.performance?.now?globalThis.performance.now():Date.now()}static _LOG_TAG="[AudioPipeline:Worklet]";_postLog(e,t,s,r){const o={message:"LOG",level:e,tag:t,text:s,data:r};try{this.port.postMessage(o)}catch{}}_forwardLog(e,t,s,r){this._postLog(e,t,s,r)}_logInfo(e,t,r=!1){(r||this._debugLogs)&&this._postLog("info",s._LOG_TAG,e,t)}_logError(e,t){this._postLog("error",s._LOG_TAG,e,t)}}registerProcessor("AudioPipelineWorklet",s)})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cc-livekit/audio-pipeline-plugin",
3
3
  "description": "A WebAssembly audio pipeline module for RNNoise and DeepFilterNet on web frontends.",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",