1import{_ as t,c as r}from"./app-core-CaVHifoP.js";import"./react-B-vVwQ3b.js";import"./router-W5KEZhfK.js";const e=r("SemanticEndpointer"),n="/ort/v1/",i="/models/smart-turn-v3.2-cpu.onnx?v=1",s=16e3,o=128e3;function a(t){const r=27/Math.log(6.4);return t>=1e3?15+Math.log(t/1e3)*r:3*t/200}function l(t){const r=Math.log(6.4)/27;return t>=15?1e3*Math.exp(r*(t-15)):200*t/3}function h(t,r,e){const n=(r-t)/(e-1);return Float64Array.from({length:e},(r,e)=>t+n*e)}function c(t=201,r=80,e=0,n=8e3,i=16e3){const s=h(a(e),a(n),r+2),o=Float64Array.from(s,l),c=h(0,Math.floor(i/2),t),u=Array.from({length:r},()=>new Array(t).fill(0));for(let a=0;a<r;a++){const r=o[a],e=o[a+1],n=o[a+2],i=2/(n-r);for(let s=0;s<t;s++){const t=c[s],o=(t-r)/(e-r),l=(n-t)/(n-e);u[a][s]=Math.max(0,Math.min(o,l))*i}}return u}function u(){t(()=>import("./ort.bundle.min-ChTdPjBy.js"),[]),t(()=>import("./transformers.web-gAv-k3YL.js"),[]),fetch(i).catch(()=>{}),fetch(`${n}ort-wasm-simd-threaded.wasm`).catch(()=>{})}class m{constructor(){this.ring=new Float32Array(o),this.ringWrite=0,this.ringFilled=0,this.session=null,this.ortTensorCtor=null,this.featureExtractor=null,this.initPromise=null,this.inferenceInFlight=!1}init(){return this.initPromise||(this.initPromise=this.doInit().catch(t=>(e.warn("Semantic endpointer unavailable â falling back to silence timer:",t),!1))),this.initPromise}async doInit(){const r=performance.now(),[a,l]=await Promise.all([t(()=>import("./ort.bundle.min-ChTdPjBy.js"),[]),t(()=>import("./transformers.web-gAv-k3YL.js"),[])]);a.env.wasm.wasmPaths=n,a.env.wasm.numThreads=1;const h=new l.WhisperFeatureExtractor({feature_size:80,sampling_rate:s,hop_length:160,chunk_length:8,n_fft:400,n_samples:o,nb_max_frames:800,padding_value:0,mel_filters:c()});return this.featureExtractor=t=>h(t),this.session=await a.InferenceSession.create(i,{executionProviders:["wasm"]}),this.ortTensorCtor=a.Tensor,e.info(`Smart Turn v3 ready in ${Math.round(performance.now()-r)}ms`),!0}push(t){for(let r=0;r<t.length;r++)this.ring[this.ringWrite]=t[r],this.ringWrite=(this.ringWrite+1)%o;this.ringFilled=Math.min(o,this.ringFilled+t.length)}reset(){this.ringWrite=0,this.ringFilled=0,this.ring.fill(0)}async probabilityComplete(){var t;if(!this.session||!this.featureExtractor||!this.ortTensorCtor)return null;if(this.inferenceInFlight||0===this.ringFilled)return null;this.inferenceInFlight=!0;try{const r=this.ringFilled,n=new Float32Array(r),i=(this.ringWrite-r+o)%o;for(let t=0;t<r;t++)n[t]=this.ring[(i+t)%o];let s=0;for(let t=0;t<r;t++)s+=n[t];s/=r;let a=0;for(let t=0;t<r;t++){const r=n[t]-s;a+=r*r}const l=Math.sqrt(a/r)||1;for(let t=0;t<r;t++)n[t]=(n[t]-s)/l;const h=performance.now(),{input_features:c}=await this.featureExtractor(n),u=new this.ortTensorCtor("float32",c.data,c.dims),m=await this.session.run({input_features:u}),f=Object.values(m)[0],g=null==(t=null==f?void 0:f.data)?void 0:t[0];return e.debug(`Smart Turn P(complete)=${null==g?void 0:g.toFixed(3)} in ${Math.round(performance.now()-h)}ms`),"number"==typeof g&&Number.isFinite(g)?g:null}catch(r){return e.warn("Smart Turn inference failed:",r),null}finally{this.inferenceInFlight=!1}}}export{m as SemanticEndpointer,u as prewarmSemanticAssets,c as whisperMelFilters};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.