Skip to content

Conversation

@cs-util
Copy link
Contributor

@cs-util cs-util commented Oct 29, 2025

This pull request introduces support for local ONNX Runtime (ORT) and Silero VAD models in the development environment, and ensures these resources are properly ignored by tooling and configuration. It also adds the compiled ORT WASM module to the repository for local execution and configures the frontend to use these local resources by default unless overridden.

Development environment setup and configuration:

  • Added default paths for local ORT WASM (/ort/) and Silero VAD ONNX (/model/silero_vad.onnx) models in index.html, allowing easy override for development without changing code.
  • Updated .eslintignore and ESLint configuration to ignore the ort/, node_modules/, and coverage/ directories, preventing linting and analysis of large or generated files. [1] [2]

Local ONNX Runtime support:

  • Added the compiled ort-training-wasm-simd-threaded.mjs module to the ort/ directory, enabling browser-based inference and training with ONNX models using WebAssembly and threading.

cs-util and others added 28 commits October 28, 2025 17:06
… cross-origin isolation requirement

Skip Invalid WASM Paths: Only set custom WASM paths if they're explicitly configured and not the default /ort/ (which doesn't exist)
Add Error Handling: Added try-catch blocks around ONNX initialization to provide cleaner error messages instead of cryptic WASM failures
…single-threaded execution for cross-origin isolation
…nt's flat config will exclude the local vendor files.

Recreated .eslintignore (removed markdown fences) and ensured it contains:
ort/
node_modules/
coverage/
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…cal model override in index.html (since the file doesn't exist), and disabled the custom WASM paths to ensure compatibility with the CDN-loaded ONNX Runtime Web
…the model URL being used and the exact error during session creation. This should help identify if the issue is with the model file, the runtime version, or the loading process
…tput frequency and update state tensor assignment
@cs-util cs-util closed this Oct 29, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @cs-util, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's speech-to-text capabilities by integrating local ONNX Runtime and Silero VAD models. It introduces robust audio processing and intelligent chunking mechanisms, allowing for more efficient and reliable transcription of large audio files. Additionally, it streamlines the development environment by updating ESLint configurations and providing a script for automated asset fetching, ensuring a smoother workflow for local model execution.

Highlights

  • Local ONNX Runtime (ORT) and Silero VAD Support: Introduces local execution for ONNX Runtime and Silero VAD models, improving performance and reducing reliance on external services for certain speech-to-text tasks. This includes adding several new ONNX Runtime WebAssembly modules.
  • ESLint Configuration Updates: Modifies ESLint rules to ignore large generated files and directories like ort/, node_modules/, and coverage/, streamlining development and linting processes.
  • Default Model Paths in index.html: Sets default paths for local ORT WASM and Silero VAD ONNX models in the main HTML file, allowing easy overrides for development without changing core code.
  • New Speech-to-Text (STT) Chunking Logic: Implements advanced audio processing, voice activity detection (VAD), and intelligent chunking strategies to optimize transcription of large audio files, improving efficiency and accuracy.
  • Enhanced transcribeFile with Prompt Support: The transcribeFile function now accepts a prompt parameter, enabling more accurate and context-aware transcriptions by providing prior conversation context to the transcription model.
  • Automated ONNX Runtime Web Asset Fetching: Adds a new shell script (scripts/fetch-onnx-dist.sh) to automate the download and setup of onnxruntime-web distribution assets, simplifying local development setup and ensuring consistent environments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant new functionality for local speech-to-text (STT) processing using ONNX Runtime and Silero VAD. The changes include adding the necessary ORT assets, scripts to fetch them, and the core logic for audio decoding, voice activity detection, and chunked transcription. My review focuses on a critical issue with checking in large binary assets, a redundancy in the ESLint configuration, and a couple of improvements for development workflow and robustness. Overall, the addition of local STT is a great feature, but the handling of the ORT assets needs to be corrected before merging.

Comment on lines +1 to +82

var ortWasmThreaded = (() => {
var _scriptName = import.meta.url;

return (
async function(moduleArg = {}) {
var moduleRtn;

function aa(){e.buffer!=l.buffer&&m();return l}function n(){e.buffer!=l.buffer&&m();return ba}function r(){e.buffer!=l.buffer&&m();return ca}function u(){e.buffer!=l.buffer&&m();return da}function ea(){e.buffer!=l.buffer&&m();return fa}var w=Object.assign({},moduleArg),ha,x,ia=new Promise((a,b)=>{ha=a;x=b}),ja="object"==typeof window,A="function"==typeof importScripts,B="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,C=A&&"em-pthread"==self.name;
if(B){const {createRequire:a}=await import("module");var require=a(import.meta.url),D=require("worker_threads");global.Worker=D.Worker;C=(A=!D.xb)&&"em-pthread"==D.workerData}"use strict";w.mountExternalData=(a,b)=>{(w.gb||(w.gb=new Map)).set(a,b)};w.unmountExternalData=()=>{delete w.gb};
var SharedArrayBuffer=globalThis.SharedArrayBuffer??(new WebAssembly.Memory({initial:0,maximum:0,shared:!0})).buffer.constructor,ka=Object.assign({},w),la="./this.program",E=(a,b)=>{throw b;},F="",ma,G,H;
if(B){var fs=require("fs"),na=require("path");F=require("url").fileURLToPath(new URL("./",import.meta.url));ma=(a,b)=>{a=oa(a)?new URL(a):na.normalize(a);return fs.readFileSync(a,b?void 0:"utf8")};H=a=>{a=ma(a,!0);a.buffer||(a=new Uint8Array(a));return a};G=(a,b,c,d=!0)=>{a=oa(a)?new URL(a):na.normalize(a);fs.readFile(a,d?void 0:"utf8",(g,h)=>{g?c(g):b(d?h.buffer:h)})};!w.thisProgram&&1<process.argv.length&&(la=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);E=(a,b)=>{process.exitCode=
a;throw b;}}else if(ja||A)A?F=self.location.href:"undefined"!=typeof document&&document.currentScript&&(F=document.currentScript.src),_scriptName&&(F=_scriptName),F.startsWith("blob:")?F="":F=F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1),B||(ma=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},A&&(H=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),G=(a,b,c)=>{var d=new XMLHttpRequest;
d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=()=>{200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)});B&&"undefined"==typeof performance&&(global.performance=require("perf_hooks").performance);var pa=console.log.bind(console),qa=console.error.bind(console);B&&(pa=(...a)=>fs.writeSync(1,a.join(" ")+"\n"),qa=(...a)=>fs.writeSync(2,a.join(" ")+"\n"));var ra=pa,I=qa;Object.assign(w,ka);ka=null;
if(C){var sa;if(B){var ta=D.parentPort;ta.on("message",b=>onmessage({data:b}));Object.assign(globalThis,{self:global,importScripts:()=>{},postMessage:b=>ta.postMessage(b),performance:global.performance||{now:Date.now}})}var ua=!1;I=function(...b){b=b.join(" ");B?fs.writeSync(2,b+"\n"):console.error(b)};self.alert=function(...b){postMessage({lb:"alert",text:b.join(" "),yb:K()})};w.instantiateWasm=(b,c)=>new Promise(d=>{sa=g=>{g=new WebAssembly.Instance(g,va());c(g);d()}});self.onunhandledrejection=
b=>{throw b.reason||b;};function a(b){try{var c=b.data,d=c.cmd;if("load"===d){let g=[];self.onmessage=h=>g.push(h);self.startWorker=()=>{postMessage({cmd:"loaded"});for(let h of g)a(h);self.onmessage=a};for(const h of c.handlers)if(!w[h]||w[h].proxy)w[h]=(...k)=>{postMessage({lb:"callHandler",wb:h,args:k})},"print"==h&&(ra=w[h]),"printErr"==h&&(I=w[h]);e=c.wasmMemory;m();sa(c.wasmModule)}else if("run"===d){wa(c.pthread_ptr,0,0,1,0,0);xa(c.pthread_ptr);ya();za();ua||=!0;try{Aa(c.start_routine,c.arg)}catch(g){if("unwind"!=
g)throw g;}}else"cancel"===d?K()&&Ba(-1):"setimmediate"!==c.target&&("checkMailbox"===d?ua&&Ca():d&&(I(`worker: received unknown command ${d}`),I(c)))}catch(g){throw Da(),g;}}self.onmessage=a}var L;w.wasmBinary&&(L=w.wasmBinary);var e,Ea,Fa=!1,M,l,ba,ca,da,N,fa;
function m(){var a=e.buffer;w.HEAP8=l=new Int8Array(a);w.HEAP16=new Int16Array(a);w.HEAPU8=ba=new Uint8Array(a);w.HEAPU16=new Uint16Array(a);w.HEAP32=ca=new Int32Array(a);w.HEAPU32=da=new Uint32Array(a);w.HEAPF32=new Float32Array(a);w.HEAPF64=fa=new Float64Array(a);w.HEAP64=N=new BigInt64Array(a);w.HEAPU64=new BigUint64Array(a)}
if(!C){e=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0});if(!(e.buffer instanceof SharedArrayBuffer))throw I("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),B&&I("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");m()}
var Ga=[],Ha=[],Ia=[],O=0,Ja=null,P=null;function Ka(){O--;if(0==O&&(null!==Ja&&(clearInterval(Ja),Ja=null),P)){var a=P;P=null;a()}}function La(a){a="Aborted("+a+")";I(a);Fa=!0;M=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");x(a);throw a;}var Ma=a=>a.startsWith("data:application/octet-stream;base64,"),oa=a=>a.startsWith("file://"),Na;function Oa(a){if(a==Na&&L)return new Uint8Array(L);if(H)return H(a);throw"both async and sync fetching of the wasm failed";}
function Pa(a){if(!L&&(ja||A)){if("function"==typeof fetch&&!oa(a))return fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw`failed to load wasm binary file at '${a}'`;return b.arrayBuffer()}).catch(()=>Oa(a));if(G)return new Promise((b,c)=>{G(a,d=>b(new Uint8Array(d)),c)})}return Promise.resolve().then(()=>Oa(a))}function Qa(a,b,c){return Pa(a).then(d=>WebAssembly.instantiate(d,b)).then(c,d=>{I(`failed to asynchronously prepare wasm: ${d}`);La(d)})}
function Ra(a,b){var c=Na;return L||"function"!=typeof WebAssembly.instantiateStreaming||Ma(c)||oa(c)||B||"function"!=typeof fetch?Qa(c,a,b):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,a).then(b,function(g){I(`wasm streaming compile failed: ${g}`);I("falling back to ArrayBuffer instantiation");return Qa(c,a,b)}))}
function va(){Sa={j:Ta,b:Ua,E:Va,g:Wa,V:Xa,A:Ya,C:Za,W:$a,T:ab,L:bb,S:cb,o:db,B:eb,y:fb,U:gb,z:hb,_:ib,Z:jb,P:kb,w:lb,F:mb,k:nb,O:xa,Y:ob,I:pb,J:qb,K:rb,G:sb,H:tb,v:ub,q:vb,l:wb,p:xb,e:yb,X:zb,x:Ab,d:Bb,f:Cb,i:Db,u:Eb,t:Fb,s:Gb,Q:Hb,R:Ib,D:Jb,h:Kb,n:Lb,M:Mb,m:Nb,a:e,r:Ob,N:Pb,c:Qb};return{a:Sa}}
var Rb={892836:(a,b,c,d)=>{if("undefined"==typeof w||!w.gb)return 1;a=Q(a>>>0);a.startsWith("./")&&(a=a.substring(2));a=w.gb.get(a);if(!a)return 2;b>>>=0;c>>>=0;d>>>=0;if(b+c>a.byteLength)return 3;try{return n().set(a.subarray(b,b+c),d>>>0),0}catch{return 4}},893337:()=>"undefined"!==typeof wasmOffsetConverter};function Ta(){return"undefined"!==typeof wasmOffsetConverter}function Sb(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}
var Tb=a=>{a.terminate();a.onmessage=()=>{}},Wb=a=>{0==R.length&&(Ub(),Vb(R[0]));var b=R.pop();if(!b)return 6;S.push(b);T[a.cb]=b;b.cb=a.cb;var c={cmd:"run",start_routine:a.pb,arg:a.nb,pthread_ptr:a.cb};B&&b.unref();b.postMessage(c,a.ub);return 0},U=0,V=(a,b,...c)=>{for(var d=2*c.length,g=$b(),h=ac(8*d),k=h>>>3,p=0;p<c.length;p++){var y=c[p];"bigint"==typeof y?(N[k+2*p]=1n,N[k+2*p+1]=y):(N[k+2*p]=0n,ea()[k+2*p+1>>>0]=y)}a=bc(a,0,d,h,b);cc(g);return a};
function Ob(a){if(C)return V(0,1,a);M=a;if(!(0<U)){for(var b of S)Tb(b);for(b of R)Tb(b);R=[];S=[];T=[];Fa=!0}E(a,new Sb(a))}function dc(a){if(C)return V(1,0,a);Jb(a)}var Jb=a=>{M=a;if(C)throw dc(a),"unwind";Ob(a)},R=[],S=[],ec=[],T={};function fc(){for(var a=w.numThreads-1;a--;)Ub();Ga.unshift(()=>{O++;gc(()=>Ka())})}var ic=a=>{var b=a.cb;delete T[b];R.push(a);S.splice(S.indexOf(a),1);a.cb=0;hc(b)};function za(){ec.forEach(a=>a())}
var Vb=a=>new Promise(b=>{a.onmessage=h=>{h=h.data;var k=h.cmd;if(h.targetThread&&h.targetThread!=K()){var p=T[h.targetThread];p?p.postMessage(h,h.transferList):I(`Internal error! Worker sent a message "${k}" to target pthread ${h.targetThread}, but that thread no longer exists!`)}else if("checkMailbox"===k)Ca();else if("spawnThread"===k)Wb(h);else if("cleanupThread"===k)ic(T[h.thread]);else if("killThread"===k)h=h.thread,k=T[h],delete T[h],Tb(k),hc(h),S.splice(S.indexOf(k),1),k.cb=0;else if("cancelThread"===
k)T[h.thread].postMessage({cmd:"cancel"});else if("loaded"===k)a.loaded=!0,B&&!a.cb&&a.unref(),b(a);else if("alert"===k)alert(`Thread ${h.threadId}: ${h.text}`);else if("setimmediate"===h.target)a.postMessage(h);else if("callHandler"===k)w[h.handler](...h.args);else k&&I(`worker sent an unknown command ${k}`)};a.onerror=h=>{I(`${"worker sent an error!"} ${h.filename}:${h.lineno}: ${h.message}`);throw h;};B&&(a.on("message",h=>a.onmessage({data:h})),a.on("error",h=>a.onerror(h)));var c=[],d=[],g;for(g of d)w.hasOwnProperty(g)&&
c.push(g);a.postMessage({cmd:"load",handlers:c,wasmMemory:e,wasmModule:Ea})});function gc(a){C?a():Promise.all(R.map(Vb)).then(a)}function Ub(){var a=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});R.push(a)}var jc=a=>{for(;0<a.length;)a.shift()(w)},ya=()=>{var a=K(),b=u()[a+52>>>2>>>0];a=u()[a+56>>>2>>>0];kc(b,b-a);cc(b)},lc=[],mc,Aa=(a,b)=>{U=0;var c=lc[a];c||(a>=lc.length&&(lc.length=a+1),lc[a]=c=mc.get(a));a=c(b);0<U?M=a:Ba(a)};
class nc{constructor(a){this.jb=a-24}}var oc=0,pc=0;function Ua(a,b,c){a>>>=0;var d=new nc(a);b>>>=0;c>>>=0;u()[d.jb+16>>>2>>>0]=0;u()[d.jb+4>>>2>>>0]=b;u()[d.jb+8>>>2>>>0]=c;oc=a;pc++;throw oc;}function qc(a,b,c,d){return C?V(2,1,a,b,c,d):Va(a,b,c,d)}
function Va(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;if("undefined"==typeof SharedArrayBuffer)return I("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var g=[];if(C&&0===g.length)return qc(a,b,c,d);a={pb:c,cb:a,nb:d,ub:g};return C?(a.lb="spawnThread",postMessage(a,g),0):Wb(a)}
var rc="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,sc=(a,b,c)=>{b>>>=0;var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.buffer&&rc)return rc.decode(a.buffer instanceof SharedArrayBuffer?a.slice(b,c):a.subarray(b,c));for(d="";b<c;){var g=a[b++];if(g&128){var h=a[b++]&63;if(192==(g&224))d+=String.fromCharCode((g&31)<<6|h);else{var k=a[b++]&63;g=224==(g&240)?(g&15)<<12|h<<6|k:(g&7)<<18|h<<12|k<<6|a[b++]&63;65536>g?d+=String.fromCharCode(g):(g-=65536,d+=String.fromCharCode(55296|g>>
10,56320|g&1023))}}else d+=String.fromCharCode(g)}return d},Q=(a,b)=>(a>>>=0)?sc(n(),a,b):"";function Wa(a,b,c){return C?V(3,1,a,b,c):0}function Xa(a,b){if(C)return V(4,1,a,b)}
var tc=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},uc=(a,b,c,d)=>{c>>>=0;if(!(0<d))return 0;var g=c;d=c+d-1;for(var h=0;h<a.length;++h){var k=a.charCodeAt(h);if(55296<=k&&57343>=k){var p=a.charCodeAt(++h);k=65536+((k&1023)<<10)|p&1023}if(127>=k){if(c>=d)break;b[c++>>>0]=k}else{if(2047>=k){if(c+1>=d)break;b[c++>>>0]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++>>>0]=224|k>>12}else{if(c+3>=d)break;b[c++>>>0]=240|k>>
18;b[c++>>>0]=128|k>>12&63}b[c++>>>0]=128|k>>6&63}b[c++>>>0]=128|k&63}}b[c>>>0]=0;return c-g},W=(a,b,c)=>uc(a,n(),b,c);function Ya(a,b){if(C)return V(5,1,a,b)}function Za(a,b,c){if(C)return V(6,1,a,b,c)}function $a(a,b,c){return C?V(7,1,a,b,c):0}function ab(a,b){if(C)return V(8,1,a,b)}function bb(a,b,c){if(C)return V(9,1,a,b,c)}function cb(a,b,c,d){if(C)return V(10,1,a,b,c,d)}function db(a,b,c,d){if(C)return V(11,1,a,b,c,d)}function eb(a,b,c,d){if(C)return V(12,1,a,b,c,d)}
function fb(a){if(C)return V(13,1,a)}function gb(a,b){if(C)return V(14,1,a,b)}function hb(a,b,c){if(C)return V(15,1,a,b,c)}var ib=()=>{La("")},jb=()=>1;function kb(a){wa(a>>>0,!A,1,!ja,131072,!1);za()}function xa(a){a>>>=0;"function"===typeof Atomics.vb&&(Atomics.vb(r(),a>>>2,a).value.then(Ca),a+=128,Atomics.store(r(),a>>>2,1))}
var Ca=()=>{var a=K();if(a&&(xa(a),a=vc,!Fa))try{if(a(),!(0<U))try{C?Ba(M):Jb(M)}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}};function lb(a,b){a>>>=0;a==b>>>0?setTimeout(Ca):C?postMessage({targetThread:a,cmd:"checkMailbox"}):(a=T[a])&&a.postMessage({cmd:"checkMailbox"})}var wc=[];function mb(a,b,c,d,g){b>>>=0;d/=2;wc.length=d;c=g>>>0>>>3;for(g=0;g<d;g++)wc[g]=N[c+2*g]?N[c+2*g+1]:ea()[c+2*g+1>>>0];return(b?Rb[b]:xc[a])(...wc)}
function nb(a){a>>>=0;C?postMessage({cmd:"cleanupThread",thread:a}):ic(T[a])}function ob(a){B&&T[a>>>0].ref()}
function pb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getUTCSeconds();r()[b+4>>>2>>>0]=a.getUTCMinutes();r()[b+8>>>2>>>0]=a.getUTCHours();r()[b+12>>>2>>>0]=a.getUTCDate();r()[b+16>>>2>>>0]=a.getUTCMonth();r()[b+20>>>2>>>0]=a.getUTCFullYear()-1900;r()[b+24>>>2>>>0]=a.getUTCDay();a=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0;r()[b+28>>>2>>>0]=a}
var X=a=>0===a%4&&(0!==a%100||0===a%400),yc=[0,31,60,91,121,152,182,213,244,274,305,335],zc=[0,31,59,90,120,151,181,212,243,273,304,334];
function qb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getSeconds();r()[b+4>>>2>>>0]=a.getMinutes();r()[b+8>>>2>>>0]=a.getHours();r()[b+12>>>2>>>0]=a.getDate();r()[b+16>>>2>>>0]=a.getMonth();r()[b+20>>>2>>>0]=a.getFullYear()-1900;r()[b+24>>>2>>>0]=a.getDay();var c=(X(a.getFullYear())?yc:zc)[a.getMonth()]+a.getDate()-1|0;r()[b+28>>>2>>>0]=c;r()[b+36>>>2>>>0]=-(60*a.getTimezoneOffset());c=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();
var d=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();a=(c!=d&&a.getTimezoneOffset()==Math.min(d,c))|0;r()[b+32>>>2>>>0]=a}
function rb(a){a>>>=0;var b=new Date(r()[a+20>>>2>>>0]+1900,r()[a+16>>>2>>>0],r()[a+12>>>2>>>0],r()[a+8>>>2>>>0],r()[a+4>>>2>>>0],r()[a>>>2>>>0],0),c=r()[a+32>>>2>>>0],d=b.getTimezoneOffset(),g=(new Date(b.getFullYear(),6,1)).getTimezoneOffset(),h=(new Date(b.getFullYear(),0,1)).getTimezoneOffset(),k=Math.min(h,g);0>c?r()[a+32>>>2>>>0]=Number(g!=h&&k==d):0<c!=(k==d)&&(g=Math.max(h,g),b.setTime(b.getTime()+6E4*((0<c?k:g)-d)));r()[a+24>>>2>>>0]=b.getDay();c=(X(b.getFullYear())?yc:zc)[b.getMonth()]+
b.getDate()-1|0;r()[a+28>>>2>>>0]=c;r()[a>>>2>>>0]=b.getSeconds();r()[a+4>>>2>>>0]=b.getMinutes();r()[a+8>>>2>>>0]=b.getHours();r()[a+12>>>2>>>0]=b.getDate();r()[a+16>>>2>>>0]=b.getMonth();r()[a+20>>>2>>>0]=b.getYear();a=b.getTime();return BigInt(isNaN(a)?-1:a/1E3)}function sb(a,b,c,d,g,h,k){return C?V(16,1,a,b,c,d,g,h,k):-52}function tb(a,b,c,d,g,h){if(C)return V(17,1,a,b,c,d,g,h)}
function ub(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;var g=(new Date).getFullYear(),h=new Date(g,0,1),k=new Date(g,6,1);g=h.getTimezoneOffset();var p=k.getTimezoneOffset(),y=Math.max(g,p);u()[a>>>2>>>0]=60*y;r()[b>>>2>>>0]=Number(g!=p);a=v=>v.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1];h=a(h);k=a(k);p<g?(W(h,c,17),W(k,d,17)):(W(h,d,17),W(k,c,17))}var Ac=[];
function vb(a,b,c){a>>>=0;b>>>=0;c>>>=0;Ac.length=0;for(var d;d=n()[b++>>>0];){var g=105!=d;g&=112!=d;c+=g&&c%8?4:0;Ac.push(112==d?u()[c>>>2>>>0]:106==d?N[c>>>3]:105==d?r()[c>>>2>>>0]:ea()[c>>>3>>>0]);c+=g?8:4}return Rb[a](...Ac)}var wb=()=>{},xb=()=>Date.now();function yb(a,b){return I(Q(a>>>0,b>>>0))}var zb=()=>{U+=1;throw"unwind";};function Ab(){return 4294901760}var Bb;Bb=()=>performance.timeOrigin+performance.now();var Cb=()=>B?require("os").cpus().length:navigator.hardwareConcurrency;
function Db(){La("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER");return 0}function Eb(a){a>>>=0;var b=n().length;if(a<=b||4294901760<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var g=Math;d=Math.max(a,d);a:{g=(g.min.call(g,4294901760,d+(65536-d%65536)%65536)-e.buffer.byteLength+65535)/65536;try{e.grow(g);m();var h=1;break a}catch(k){}h=void 0}if(h)return!0}return!1}
var Bc=()=>{La("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER");return 0},Y={},Cc=a=>{a.forEach(b=>{var c=Bc();c&&(Y[c]=b)})};function Fb(){var a=Error().stack.toString().split("\n");"Error"==a[0]&&a.shift();Cc(a);Y.mb=Bc();Y.ob=a;return Y.mb}
function Gb(a,b,c){a>>>=0;b>>>=0;if(Y.mb==a)var d=Y.ob;else d=Error().stack.toString().split("\n"),"Error"==d[0]&&d.shift(),Cc(d);for(var g=3;d[g]&&Bc()!=a;)++g;for(a=0;a<c&&d[a+g];++a)r()[b+4*a>>>2>>>0]=Bc();return a}
var Dc={},Fc=()=>{if(!Ec){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:la||"./this.program"},b;for(b in Dc)void 0===Dc[b]?delete a[b]:a[b]=Dc[b];var c=[];for(b in a)c.push(`${b}=${a[b]}`);Ec=c}return Ec},Ec;
function Hb(a,b){if(C)return V(18,1,a,b);a>>>=0;b>>>=0;var c=0;Fc().forEach((d,g)=>{var h=b+c;g=u()[a+4*g>>>2>>>0]=h;for(h=0;h<d.length;++h)aa()[g++>>>0]=d.charCodeAt(h);aa()[g>>>0]=0;c+=d.length+1});return 0}function Ib(a,b){if(C)return V(19,1,a,b);a>>>=0;b>>>=0;var c=Fc();u()[a>>>2>>>0]=c.length;var d=0;c.forEach(g=>d+=g.length+1);u()[b>>>2>>>0]=d;return 0}function Kb(a){return C?V(20,1,a):52}function Lb(a,b,c,d){return C?V(21,1,a,b,c,d):52}function Mb(a,b,c,d){return C?V(22,1,a,b,c,d):70}
var Gc=[null,[],[]];function Nb(a,b,c,d){if(C)return V(23,1,a,b,c,d);b>>>=0;c>>>=0;d>>>=0;for(var g=0,h=0;h<c;h++){var k=u()[b>>>2>>>0],p=u()[b+4>>>2>>>0];b+=8;for(var y=0;y<p;y++){var v=n()[k+y>>>0],z=Gc[a];0===v||10===v?((1===a?ra:I)(sc(z,0)),z.length=0):z.push(v)}g+=p}u()[d>>>2>>>0]=g;return 0}var Hc=[31,29,31,30,31,30,31,31,30,31,30,31],Ic=[31,28,31,30,31,30,31,31,30,31,30,31];function Jc(a){var b=Array(tc(a)+1);uc(a,b,0,b.length);return b}var Kc=(a,b)=>{aa().set(a,b>>>0)};
function Pb(a,b,c,d){function g(f,q,t){for(f="number"==typeof f?f.toString():f||"";f.length<q;)f=t[0]+f;return f}function h(f,q){return g(f,q,"0")}function k(f,q){function t(Xb){return 0>Xb?-1:0<Xb?1:0}var J;0===(J=t(f.getFullYear()-q.getFullYear()))&&0===(J=t(f.getMonth()-q.getMonth()))&&(J=t(f.getDate()-q.getDate()));return J}function p(f){switch(f.getDay()){case 0:return new Date(f.getFullYear()-1,11,29);case 1:return f;case 2:return new Date(f.getFullYear(),0,3);case 3:return new Date(f.getFullYear(),
0,2);case 4:return new Date(f.getFullYear(),0,1);case 5:return new Date(f.getFullYear()-1,11,31);case 6:return new Date(f.getFullYear()-1,11,30)}}function y(f){var q=f.eb;for(f=new Date((new Date(f.fb+1900,0,1)).getTime());0<q;){var t=f.getMonth(),J=(X(f.getFullYear())?Hc:Ic)[t];if(q>J-f.getDate())q-=J-f.getDate()+1,f.setDate(1),11>t?f.setMonth(t+1):(f.setMonth(0),f.setFullYear(f.getFullYear()+1));else{f.setDate(f.getDate()+q);break}}t=new Date(f.getFullYear()+1,0,4);q=p(new Date(f.getFullYear(),
0,4));t=p(t);return 0>=k(q,f)?0>=k(t,f)?f.getFullYear()+1:f.getFullYear():f.getFullYear()-1}a>>>=0;b>>>=0;c>>>=0;d>>>=0;var v=u()[d+40>>>2>>>0];d={sb:r()[d>>>2>>>0],rb:r()[d+4>>>2>>>0],hb:r()[d+8>>>2>>>0],kb:r()[d+12>>>2>>>0],ib:r()[d+16>>>2>>>0],fb:r()[d+20>>>2>>>0],bb:r()[d+24>>>2>>>0],eb:r()[d+28>>>2>>>0],zb:r()[d+32>>>2>>>0],qb:r()[d+36>>>2>>>0],tb:v?Q(v):""};c=Q(c);v={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y",
"%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var z in v)c=c.replace(new RegExp(z,"g"),v[z]);var Yb="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Zb="January February March April May June July August September October November December".split(" ");v={"%a":f=>Yb[f.bb].substring(0,3),
"%A":f=>Yb[f.bb],"%b":f=>Zb[f.ib].substring(0,3),"%B":f=>Zb[f.ib],"%C":f=>h((f.fb+1900)/100|0,2),"%d":f=>h(f.kb,2),"%e":f=>g(f.kb,2," "),"%g":f=>y(f).toString().substring(2),"%G":y,"%H":f=>h(f.hb,2),"%I":f=>{f=f.hb;0==f?f=12:12<f&&(f-=12);return h(f,2)},"%j":f=>{for(var q=0,t=0;t<=f.ib-1;q+=(X(f.fb+1900)?Hc:Ic)[t++]);return h(f.kb+q,3)},"%m":f=>h(f.ib+1,2),"%M":f=>h(f.rb,2),"%n":()=>"\n","%p":f=>0<=f.hb&&12>f.hb?"AM":"PM","%S":f=>h(f.sb,2),"%t":()=>"\t","%u":f=>f.bb||7,"%U":f=>h(Math.floor((f.eb+
7-f.bb)/7),2),"%V":f=>{var q=Math.floor((f.eb+7-(f.bb+6)%7)/7);2>=(f.bb+371-f.eb-2)%7&&q++;if(q)53==q&&(t=(f.bb+371-f.eb)%7,4==t||3==t&&X(f.fb)||(q=1));else{q=52;var t=(f.bb+7-f.eb-1)%7;(4==t||5==t&&X(f.fb%400-1))&&q++}return h(q,2)},"%w":f=>f.bb,"%W":f=>h(Math.floor((f.eb+7-(f.bb+6)%7)/7),2),"%y":f=>(f.fb+1900).toString().substring(2),"%Y":f=>f.fb+1900,"%z":f=>{f=f.qb;var q=0<=f;f=Math.abs(f)/60;return(q?"+":"-")+String("0000"+(f/60*100+f%60)).slice(-4)},"%Z":f=>f.tb,"%%":()=>"%"};c=c.replace(/%%/g,
"\x00\x00");for(z in v)c.includes(z)&&(c=c.replace(new RegExp(z,"g"),v[z](d)));c=c.replace(/\0\0/g,"%");z=Jc(c);if(z.length>b)return 0;Kc(z,a);return z.length-1}function Qb(a,b,c,d){return Pb(a>>>0,b>>>0,c>>>0,d>>>0)}C||fc();
var xc=[Ob,dc,qc,Wa,Xa,Ya,Za,$a,ab,bb,cb,db,eb,fb,gb,hb,sb,tb,Hb,Ib,Kb,Lb,Mb,Nb],Sa,Z=function(){function a(c,d){Z=c.exports;Z=Lc();ec.push(Z.Ra);mc=Z.Sa;Ha.unshift(Z.$);Ea=d;Ka();return Z}var b=va();O++;if(w.instantiateWasm)try{return w.instantiateWasm(b,a)}catch(c){I(`Module.instantiateWasm callback failed with error: ${c}`),x(c)}Na||=w.locateFile?Ma("ort-training-wasm-simd-threaded.wasm")?"ort-training-wasm-simd-threaded.wasm":w.locateFile?w.locateFile("ort-training-wasm-simd-threaded.wasm",F):
F+"ort-training-wasm-simd-threaded.wasm":(new URL("ort-training-wasm-simd-threaded.wasm",import.meta.url)).href;Ra(b,function(c){a(c.instance,c.module)}).catch(x);return{}}();w._OrtInit=(a,b)=>(w._OrtInit=Z.aa)(a,b);w._OrtGetLastError=(a,b)=>(w._OrtGetLastError=Z.ba)(a,b);w._OrtCreateSessionOptions=(a,b,c,d,g,h,k,p,y,v)=>(w._OrtCreateSessionOptions=Z.ca)(a,b,c,d,g,h,k,p,y,v);w._OrtAppendExecutionProvider=(a,b)=>(w._OrtAppendExecutionProvider=Z.da)(a,b);
w._OrtAddFreeDimensionOverride=(a,b,c)=>(w._OrtAddFreeDimensionOverride=Z.ea)(a,b,c);w._OrtAddSessionConfigEntry=(a,b,c)=>(w._OrtAddSessionConfigEntry=Z.fa)(a,b,c);w._OrtReleaseSessionOptions=a=>(w._OrtReleaseSessionOptions=Z.ga)(a);w._OrtCreateSession=(a,b,c)=>(w._OrtCreateSession=Z.ha)(a,b,c);w._OrtReleaseSession=a=>(w._OrtReleaseSession=Z.ia)(a);w._OrtGetInputOutputCount=(a,b,c)=>(w._OrtGetInputOutputCount=Z.ja)(a,b,c);w._OrtGetInputName=(a,b)=>(w._OrtGetInputName=Z.ka)(a,b);
w._OrtGetOutputName=(a,b)=>(w._OrtGetOutputName=Z.la)(a,b);w._OrtFree=a=>(w._OrtFree=Z.ma)(a);w._OrtCreateTensor=(a,b,c,d,g,h)=>(w._OrtCreateTensor=Z.na)(a,b,c,d,g,h);w._OrtGetTensorData=(a,b,c,d,g)=>(w._OrtGetTensorData=Z.oa)(a,b,c,d,g);w._OrtReleaseTensor=a=>(w._OrtReleaseTensor=Z.pa)(a);w._OrtCreateRunOptions=(a,b,c,d)=>(w._OrtCreateRunOptions=Z.qa)(a,b,c,d);w._OrtAddRunConfigEntry=(a,b,c)=>(w._OrtAddRunConfigEntry=Z.ra)(a,b,c);w._OrtReleaseRunOptions=a=>(w._OrtReleaseRunOptions=Z.sa)(a);
w._OrtCreateBinding=a=>(w._OrtCreateBinding=Z.ta)(a);w._OrtBindInput=(a,b,c)=>(w._OrtBindInput=Z.ua)(a,b,c);w._OrtBindOutput=(a,b,c,d)=>(w._OrtBindOutput=Z.va)(a,b,c,d);w._OrtClearBoundOutputs=a=>(w._OrtClearBoundOutputs=Z.wa)(a);w._OrtReleaseBinding=a=>(w._OrtReleaseBinding=Z.xa)(a);w._OrtRunWithBinding=(a,b,c,d,g)=>(w._OrtRunWithBinding=Z.ya)(a,b,c,d,g);w._OrtRun=(a,b,c,d,g,h,k,p)=>(w._OrtRun=Z.za)(a,b,c,d,g,h,k,p);w._OrtEndProfiling=a=>(w._OrtEndProfiling=Z.Aa)(a);
w._OrtTrainingLoadCheckpoint=(a,b)=>(w._OrtTrainingLoadCheckpoint=Z.Ba)(a,b);w._OrtTrainingReleaseCheckpoint=a=>(w._OrtTrainingReleaseCheckpoint=Z.Ca)(a);w._OrtTrainingCreateSession=(a,b,c,d,g,h,k,p)=>(w._OrtTrainingCreateSession=Z.Da)(a,b,c,d,g,h,k,p);w._OrtTrainingLazyResetGrad=a=>(w._OrtTrainingLazyResetGrad=Z.Ea)(a);w._OrtTrainingRunTrainStep=(a,b,c,d,g,h)=>(w._OrtTrainingRunTrainStep=Z.Fa)(a,b,c,d,g,h);w._OrtTrainingOptimizerStep=(a,b)=>(w._OrtTrainingOptimizerStep=Z.Ga)(a,b);
w._OrtTrainingEvalStep=(a,b,c,d,g,h)=>(w._OrtTrainingEvalStep=Z.Ha)(a,b,c,d,g,h);w._OrtTrainingGetParametersSize=(a,b,c)=>(w._OrtTrainingGetParametersSize=Z.Ia)(a,b,c);w._OrtTrainingCopyParametersToBuffer=(a,b,c,d)=>(w._OrtTrainingCopyParametersToBuffer=Z.Ja)(a,b,c,d);w._OrtTrainingCopyParametersFromBuffer=(a,b,c,d)=>(w._OrtTrainingCopyParametersFromBuffer=Z.Ka)(a,b,c,d);w._OrtTrainingGetModelInputOutputCount=(a,b,c,d)=>(w._OrtTrainingGetModelInputOutputCount=Z.La)(a,b,c,d);
w._OrtTrainingGetModelInputOutputName=(a,b,c,d)=>(w._OrtTrainingGetModelInputOutputName=Z.Ma)(a,b,c,d);w._OrtTrainingReleaseSession=a=>(w._OrtTrainingReleaseSession=Z.Na)(a);var K=()=>(K=Z.Oa)();w._malloc=a=>(w._malloc=Z.Pa)(a);w._free=a=>(w._free=Z.Qa)(a);var wa=(a,b,c,d,g,h)=>(wa=Z.Ta)(a,b,c,d,g,h),Da=()=>(Da=Z.Ua)(),bc=(a,b,c,d,g)=>(bc=Z.Va)(a,b,c,d,g),hc=a=>(hc=Z.Wa)(a),Ba=a=>(Ba=Z.Xa)(a),vc=()=>(vc=Z.Ya)(),kc=(a,b)=>(kc=Z.Za)(a,b),cc=a=>(cc=Z._a)(a),ac=a=>(ac=Z.$a)(a),$b=()=>($b=Z.ab)();
w.___start_em_js=893394;w.___stop_em_js=893455;function Lc(){var a=Z;a=Object.assign({},a);var b=d=>()=>d()>>>0,c=d=>g=>d(g)>>>0;a.Oa=b(a.Oa);a.Pa=c(a.Pa);a.emscripten_main_runtime_thread_id=b(a.emscripten_main_runtime_thread_id);a.$a=c(a.$a);a.ab=b(a.ab);return a}w.stackSave=()=>$b();w.stackRestore=a=>cc(a);w.stackAlloc=a=>ac(a);w.UTF8ToString=Q;w.stringToUTF8=W;w.lengthBytesUTF8=tc;var Mc;P=function Nc(){Mc||Oc();Mc||(P=Nc)};
function Oc(){0<O||(C?(ha(w),C||jc(Ha),startWorker(w)):(jc(Ga),0<O||Mc||(Mc=!0,w.calledRun=!0,Fa||(C||jc(Ha),ha(w),C||jc(Ia)))))}Oc();moduleRtn=ia;


return moduleRtn;
}
);
})();
export default ortWasmThreaded;
var isPthread = globalThis.self?.name === 'em-pthread';
var isNode = typeof globalThis.process?.versions?.node == 'string';
if (isNode) isPthread = (await import('worker_threads')).workerData === 'em-pthread';

// When running as a pthread, construct a new instance on startup
isPthread && ortWasmThreaded();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Checking large, compiled third-party library files into the repository is strongly discouraged. It significantly increases the repository size, slows down cloning and other Git operations, and makes updating the dependency more difficult. This pull request correctly adds a scripts/fetch-onnx-dist.sh script to download these assets. The ort/ directory should be added to the project's .gitignore file, and developers should be instructed to run the fetch script as part of the project setup. Please remove the ort/ directory and its contents from this pull request.

Comment on lines +18 to +22
const candidates = [
'https://esm.sh/onnxruntime-web@1.19.0',
'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.19.0/dist/ort.esm.js',
'https://unpkg.com/onnxruntime-web@1.19.0/dist/ort.esm.js',
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The ensureOrt function attempts to load onnxruntime-web from various CDNs, but it doesn't prioritize the local copy in /ort/ that this PR is adding. The primary purpose of vendoring these assets is to use them for local development to ensure stability and avoid reliance on external networks. The code should be updated to first attempt loading from the local path defined in DEFAULT_ORT_WASM_PATH.

Suggested change
const candidates = [
'https://esm.sh/onnxruntime-web@1.19.0',
'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.19.0/dist/ort.esm.js',
'https://unpkg.com/onnxruntime-web@1.19.0/dist/ort.esm.js',
];
const candidates = [
`${DEFAULT_ORT_WASM_PATH}ort.min.mjs`,
'https://esm.sh/onnxruntime-web@1.19.0',
'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.19.0/dist/ort.esm.js',
'https://unpkg.com/onnxruntime-web@1.19.0/dist/ort.esm.js',
];


# Use npm pack to download the package tarball
echo "Downloading npm package..."
npm pack "onnxruntime-web@$VERSION" >/dev/null 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The output of the npm pack command is redirected to /dev/null. While this keeps the script output clean, it also hides any warnings or errors from npm, which could be important for debugging if the package download fails. It's better to let npm write to the console and only redirect if the output is excessively verbose and known to be safe to ignore.

Suggested change
npm pack "onnxruntime-web@$VERSION" >/dev/null 2>&1
npm pack "onnxruntime-web@$VERSION"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants