1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},r=(new e.Error).stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="ae4b8f3c-ace1-435e-83de-8119ab5a0bae",e._sentryDebugIdIdentifier="sentry-dbid-ae4b8f3c-ace1-435e-83de-8119ab5a0bae")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8305],{48305:(e,r,t)=>{t.d(r,{transcribeCaptionFileLocallyInBrowser:()=>i});class o{ensureWorker(){return this.worker||(this.worker=new Worker(t.tu(new URL(t.p+t.u(8316),t.b)),{type:void 0}),this.worker.onmessage=e=>{let r=e.data;if(!r||"string"!=typeof r.requestId)return;let t=this.pending.get(r.requestId);if(t){if("TRANSCRIBE_PROGRESS"===r.type)return void t.onProgress?.({stage:r.stage,detail:r.detail,progress:r.progress});"TRANSCRIBE_SUCCESS"===r.type?t.resolve(r):t.reject(Error(r.error||"Local browser transcription failed")),this.pending.delete(r.requestId)}},this.worker.onerror=e=>{let r=Error(e.message||"Local transcription worker crashed"),t=[...this.pending.values()];for(let e of(this.pending.clear(),t))e.reject(r);this.worker?.terminate(),this.worker=null}),this.worker}async transcribeAudioData(e,r,t){let o=this.ensureWorker(),s=`local-transcription-${Date.now()}-${this.requestCounter++}`;return new Promise((a,i)=>{this.pending.set(s,{resolve:a,reject:i,onProgress:t?.onProgress}),o.postMessage({type:"TRANSCRIBE_LOCAL_AUDIO",requestId:s,audioData:e,sampleRate:r},[e.buffer])})}dispose(){this.worker?.terminate(),this.worker=null,this.pending.clear()}constructor(){this.worker=null,this.requestCounter=0,this.pending=new Map}}let s=new o;async function a(e,r){r?.({stage:"decoding_audio",progress:10,detail:"Reading local media file..."});let t=await e.arrayBuffer(),o=window.AudioContext||window.webkitAudioContext;if(!o)throw Error("This browser does not support Web Audio decoding for local transcription.");let s=new o;try{r?.({stage:"decoding_audio",progress:35,detail:"Decoding audio track in browser..."});let e=await s.decodeAudioData(t.slice(0)),o=e.numberOfChannels,a=e.length;if(o<=0||a<=0)throw Error("Decoded audio is empty.");r?.({stage:"decoding_audio",progress:70,detail:"Preparing mono audio samples..."});let i=new Float32Array(a);for(let r=0;r<o;r+=1){let t=e.getChannelData(r);for(let e=0;e<a;e+=1)i[e]+=t[e]/o}if(16e3!==e.sampleRate){r?.({stage:"decoding_audio",progress:85,detail:"Resampling audio to 16kHz for Whisper..."});let t=e.sampleRate/16e3,o=Math.max(1,Math.floor(i.length/t)),s=new Float32Array(o);for(let e=0;e<o;e+=1){let r=e*t,o=Math.floor(r),a=Math.min(o+1,i.length-1),n=r-o;s[e]=i[o]*(1-n)+i[a]*n}return r?.({stage:"decoding_audio",progress:100,detail:"Audio decode complete."}),{channelData:s,sampleRate:16e3}}return r?.({stage:"decoding_audio",progress:100,detail:"Audio decode complete."}),{channelData:i,sampleRate:e.sampleRate}}catch(e){throw Error(e instanceof Error?`Browser could not decode this media file for local transcription: ${e.message}`:"Browser could not decode this media file for local transcription.")}finally{await s.close().catch(()=>void 0)}}async function i(e,r){try{let{channelData:t,sampleRate:o}=await a(e,r?.onProgress),i=await s.transcribeAudioData(t,o,r),n=i.segments.map(e=>({start:e.start,end:e.end,text:e.text,confidence:void 0,words:e.words?.map(e=>({word:e.word,start:e.start,end:e.end,probability:e.probability}))}));return{success:!0,modelId:i.modelId,text:i.text,segments:n}}catch(e){return{success:!1,segments:[],errorMessage:e instanceof Error?e.message:"Local browser transcription failed unexpectedly."}}}}}]);
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.