Spaces:
Running
Running
Download decoder_worker.mjs from Oomni/mithi-tiny-demo: direct link, hf CLI and curl.
- Browser
- Download file 825 Bytes
-
https://huggingface.co/spaces/Oomni/mithi-tiny-demo/resolve/main/decoder_worker.mjs
- Command line
-
hf download hf://spaces/Oomni/mithi-tiny-demo/decoder_worker.mjs
-
curl -L -o decoder_worker.mjs https://huggingface.co/spaces/Oomni/mithi-tiny-demo/resolve/main/decoder_worker.mjs
825 Bytes
| import*as ort from"./vendor/ort/ort.wasm.min.mjs";let session=null,chain=Promise.resolve();self.onmessage=e=>{const m=e.data;chain=chain.then((async()=>{try{if("init"===m.type)ort.env.wasm.numThreads=m.threads,ort.env.wasm.wasmPaths=m.paths,session=await ort.InferenceSession.create(m.model,{executionProviders:["wasm"],graphOptimizationLevel:"disabled"}),self.postMessage({type:"ready"});else if("run"===m.type){const f=m.f,T=(d,t,s)=>new ort.Tensor(t,d,s),audio=(await session.run({ids:T(f.ids,"int64",[1,f.Nd]),aln:T(f.aln,"float32",[1,f.Nd,f.T]),f0:T(f.f0,"float32",[1,2*f.T]),en:T(f.en,"float32",[1,2*f.T]),style:T(f.style,"float32",[1,128])})).audio.data;self.postMessage({type:"audio",id:m.id,audio:audio},[audio.buffer])}}catch(err){self.postMessage({type:"error",id:m.id,message:String(err&&err.message||err)})}}))}; |