PageSourceSearch

https://getbutlr.ai/assets/fastAudio-DVgpHROz.js

js getbutlr.ai collected 2026-10-02 01:11:38 UTC 3,916 bytes, 1 lines download raw bytes

1const k=4,I=2,x=150,N=2400;function C(n,h=2,t=150,r=2400){const o=Math.max(0,Math.min(n,r));if(o<=0)return[];const a=Math.ceil(o/t),d=Math.max(1,Math.min(h,a)),u=Math.ceil(a/d),e=[];for(let s=0;s<d;s+=1){const i=s*u*t;if(i>=o)break;e.push({startSeconds:i,endSeconds:Math.min(o,(s+1)*u*t)})}return e}function F(n,h){const t=new ArrayBuffer(44+n.length*2),r=new DataView(t),o=(a,d)=>{for(let u=0;u<d.length;u+=1)r.setUint8(a+u,d.charCodeAt(u))};o(0,"RIFF"),r.setUint32(4,36+n.length*2,!0),o(8,"WAVE"),o(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,Math.round(h),!0),r.setUint32(28,Math.round(h)*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),o(36,"data"),r.setUint32(40,n.length*2,!0);for(let a=0;a<n.length;a+=1){const d=Math.max(-1,Math.min(1,n[a]));r.setInt16(44+a*2,d<0?d*32768:d*32767,!0)}return new Blob([t],{type:"audio/wav"})}function v(n){if(!n.length)return 0;let h=0;for(let t=0;t<n.length;t+=1)h+=n[t]*n[t];return Math.sqrt(h/n.length)}async function L(n,h,t,r,o,a,d,u){const e=document.createElement("audio");e.src=h,e.preload="auto",e.preservesPitch=!1,e.mozPreservesPitch=!1,e.webkitPreservesPitch=!1,await new Promise((A,c)=>{e.onloadedmetadata=()=>A(),e.onerror=()=>c(new Error("The video audio could not be loaded."))}),t.startSeconds>0&&await new Promise(A=>{e.onseeked=()=>A(),e.currentTime=t.startSeconds}),e.playbackRate=r;const s=n.createMediaElementSource(e),i=n.createScriptProcessor(4096,2,1),U=n.createGain();U.gain.value=0,s.connect(i),i.connect(U),U.connect(n.destination);const M=n.sampleRate/r,S=Math.round(o*M);let _=Math.round((t.endSeconds-t.startSeconds)*M);const y=Math.round(M*.5);let p=[],b=0,E=0,g=0;const O=[],P=A=>{for(;b>=S||A&&b>y;){const c=Math.min(S,b),f=new Float32Array(c);let m=0;for(;m<c;){const l=p[0],w=Math.min(l.length,c-m);f.set(l.subarray(0,w),m),m+=w,w===l.length?p.shift():p[0]=l.subarray(w)}b-=c,g=Math.max(g,v(f)),O.push(d({index:a+E,startSeconds:t.startSeconds+E*o,durationSeconds:c/M,blob:F(f,M)})),E+=1}};let T=!1;i.onaudioprocess=A=>{if(!T)return;const c=A.inputBuffer,f=c.getChannelData(0),m=c.numberOfChannels>1?c.getChannelData(1):f,l=Math.min(f.length,_);if(l<=0)return;const w=new Float32Array(l);for(let D=0;D<l;D+=1)w[D]=(f[D]+m[D])*.5;_-=l,p.push(w),b+=w.length,P(!1)};try{if(await n.resume(),T=!0,await e.play(),await new Promise((A,c)=>{let f=e.currentTime,m=0;const l=()=>{if(u?.aborted){c(new DOMException("Aborted","AbortError"));return}if(e.ended||e.currentTime>=t.endSeconds){A();return}if(m=e.currentTime===f?m+1:0,f=e.currentTime,m>40){c(new Error("Audio playback stalled during fast extraction."));return}setTimeout(l,250)};l()}),T=!1,e.pause(),P(!0),await Promise.all(O),E>0&&g<1e-4)throw new Error("Fast extraction captured silence.");return E}finally{T=!1,p=[],i.onaudioprocess=null;try{s.disconnect(),i.disconnect(),U.disconnect()}catch{}e.removeAttribute("src"),e.load()}}async function R(n,h,t={}){if(typeof AudioContext>"u")throw new Error("Web Audio is not available.");const r=t.speed??4,o=t.chunkSeconds??150,a=t.maxSeconds??2400,d=Date.now(),u=URL.createObjectURL(n),e=new AudioContext;try{const s=document.createElement("audio");s.src=u,s.preload="metadata";const i=await new Promise((S,_)=>{s.onloadedmetadata=()=>S(s.duration),s.onerror=()=>_(new Error("The video audio could not be loaded."))});if(s.removeAttribute("src"),s.load(),!Number.isFinite(i)||i<=0)throw new Error("The video duration could not be read.");const U=C(i,t.parallel??2,o,a),M=await Promise.all(U.map(S=>L(e,u,S,r,o,Math.round(S.startSeconds/o),h,t.signal)));return{durationSeconds:Math.min(i,a),truncated:i>a,chunks:M.reduce((S,_)=>S+_,0),elapsedMs:Date.now()-d}}finally{URL.revokeObjectURL(u),e.close()}}export{x as FAST_AUDIO_CHUNK_SECONDS,N as FAST_AUDIO_MAX_SECONDS,I as FAST_AUDIO_PARALLEL,k as FAST_AUDIO_SPEED,F as encodeWavMono16,R as extractSpeechChunks,C as planSegments,v as rootMeanSquare};

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.