nekomeowww commited on
Commit
e803fa4
·
1 Parent(s): d864f4f

release: build da5a176205751cf53b75b71c829369ff61ba9d0d

Browse files
assets/{index-DkY1r9ic.js → index-CWirHJ3J.js} RENAMED
@@ -14,4 +14,4 @@
14
  * @vue/runtime-dom v3.5.13
15
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
16
  * @license MIT
17
- **/let qn;const Ns=typeof window<"u"&&window.trustedTypes;if(Ns)try{qn=Ns.createPolicy("vue",{createHTML:e=>e})}catch{}const ui=qn?e=>qn.createHTML(e):e=>e,dl="http://www.w3.org/2000/svg",hl="http://www.w3.org/1998/Math/MathML",He=typeof document<"u"?document:null,Ls=He&&He.createElement("template"),pl={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?He.createElementNS(dl,e):t==="mathml"?He.createElementNS(hl,e):n?He.createElement(e,{is:n}):He.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>He.createTextNode(e),createComment:e=>He.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>He.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,i){const o=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{Ls.innerHTML=ui(s==="svg"?`<svg>${e}</svg>`:s==="mathml"?`<math>${e}</math>`:e);const l=Ls.content;if(s==="svg"||s==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},gl=Symbol("_vtc");function ml(e,t,n){const s=e[gl];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Vs=Symbol("_vod"),vl=Symbol("_vsh"),bl=Symbol(""),_l=/(^|;)\s*display\s*:/;function yl(e,t,n){const s=e.style,r=Q(n);let i=!1;if(n&&!r){if(t)if(Q(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();n[l]==null&&Yt(s,l,"")}else for(const o in t)n[o]==null&&Yt(s,o,"");for(const o in n)o==="display"&&(i=!0),Yt(s,o,n[o])}else if(r){if(t!==n){const o=s[bl];o&&(n+=";"+o),s.cssText=n,i=_l.test(n)}}else t&&e.removeAttribute("style");Vs in e&&(e[Vs]=i?s.display:"",e[vl]&&(s.display="none"))}const $s=/\s*!important$/;function Yt(e,t,n){if(M(n))n.forEach(s=>Yt(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=xl(e,t);$s.test(n)?e.setProperty(Ye(s),n.replace($s,""),"important"):e[s]=n}}const Hs=["Webkit","Moz","ms"],In={};function xl(e,t){const n=In[t];if(n)return n;let s=Ke(t);if(s!=="filter"&&s in e)return In[t]=s;s=rr(s);for(let r=0;r<Hs.length;r++){const i=Hs[r]+s;if(i in e)return In[t]=i}return t}const Us="http://www.w3.org/1999/xlink";function ks(e,t,n,s,r,i=Ci(t)){s&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(Us,t.slice(6,t.length)):e.setAttributeNS(Us,t,n):n==null||i&&!lr(n)?e.removeAttribute(t):e.setAttribute(t,i?"":Le(n)?String(n):n)}function Ws(e,t,n,s,r){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?ui(n):n);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const l=i==="OPTION"?e.getAttribute("value")||"":e.value,c=n==null?e.type==="checkbox"?"on":"":String(n);(l!==c||!("_value"in e))&&(e.value=c),n==null&&e.removeAttribute(t),e._value=n;return}let o=!1;if(n===""||n==null){const l=typeof e[t];l==="boolean"?n=lr(n):n==null&&l==="string"?(n="",o=!0):l==="number"&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(r||t)}function fi(e,t,n,s){e.addEventListener(t,n,s)}function wl(e,t,n,s){e.removeEventListener(t,n,s)}const Bs=Symbol("_vei");function Sl(e,t,n,s,r=null){const i=e[Bs]||(e[Bs]={}),o=i[t];if(s&&o)o.value=s;else{const[l,c]=Cl(t);if(s){const d=i[t]=El(s,r);fi(e,l,d,c)}else o&&(wl(e,l,o,c),i[t]=void 0)}}const Ks=/(?:Once|Passive|Capture)$/;function Cl(e){let t;if(Ks.test(e)){t={};let s;for(;s=e.match(Ks);)e=e.slice(0,e.length-s[0].length),t[s[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):Ye(e.slice(2)),t]}let Dn=0;const Tl=Promise.resolve(),Al=()=>Dn||(Tl.then(()=>Dn=0),Dn=Date.now());function El(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;Ve(Ol(s,n.value),t,5,[s])};return n.value=e,n.attached=Al(),n}function Ol(e,t){if(M(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const qs=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Pl=(e,t,n,s,r,i)=>{const o=r==="svg";t==="class"?ml(e,s,o):t==="style"?yl(e,n,s):on(t)?Jn(t)||Sl(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Ml(e,t,s,o))?(Ws(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ks(e,t,s,o,i,t!=="value")):e._isVueCE&&(/[A-Z]/.test(t)||!Q(s))?Ws(e,Ke(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),ks(e,t,s,o))};function Ml(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&qs(t)&&I(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return qs(t)&&Q(n)?!1:t in e}const Gs=e=>{const t=e.props["onUpdate:modelValue"]||!1;return M(t)?n=>Gt(t,n):t},Fn=Symbol("_assign"),ai={deep:!0,created(e,{value:t,modifiers:{number:n}},s){const r=ln(t);fi(e,"change",()=>{const i=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?or(rn(o)):rn(o));e[Fn](e.multiple?r?new Set(i):i:i[0]),e._assigning=!0,Pr(()=>{e._assigning=!1})}),e[Fn]=Gs(s)},mounted(e,{value:t}){zs(e,t)},beforeUpdate(e,t,n){e[Fn]=Gs(n)},updated(e,{value:t}){e._assigning||zs(e,t)}};function zs(e,t){const n=e.multiple,s=M(t);if(!(n&&!s&&!ln(t))){for(let r=0,i=e.options.length;r<i;r++){const o=e.options[r],l=rn(o);if(n)if(s){const c=typeof l;c==="string"||c==="number"?o.selected=t.some(d=>String(d)===String(l)):o.selected=Ai(t,l)>-1}else o.selected=t.has(l);else if(fn(rn(o),t)){e.selectedIndex!==r&&(e.selectedIndex=r);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function rn(e){return"_value"in e?e._value:e.value}const Rl=le({patchProp:Pl},pl);let Js;function Il(){return Js||(Js=Lo(Rl))}const Dl=(...e)=>{const t=Il().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=jl(s);if(!r)return;const i=t._component;!I(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=n(r,!1,Fl(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t};function Fl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function jl(e){return Q(e)?document.querySelector(e):e}const Nl="/logo.png";function yn(e){return fr()?(Oi(e),!0):!1}function Be(e){return typeof e=="function"?e():Fe(e)}const ds=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ll=e=>e!=null,Vl=Object.prototype.toString,$l=e=>Vl.call(e)==="[object Object]",Gn=()=>{};function Hl(e,t){function n(...s){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,s),{fn:t,thisArg:this,args:s})).then(r).catch(i)})}return n}function Ul(e,t={}){let n,s,r=Gn;const i=l=>{clearTimeout(l),r(),r=Gn};return l=>{const c=Be(e),d=Be(t.maxWait);return n&&i(n),c<=0||d!==void 0&&d<=0?(s&&(i(s),s=null),Promise.resolve(l())):new Promise((f,h)=>{r=t.rejectOnCancel?h:f,d&&!s&&(s=setTimeout(()=>{n&&i(n),s=null,f(l())},d)),n=setTimeout(()=>{s&&i(s),s=null,f(l())},c)})}}function kl(e){let t;function n(){return t||(t=e()),t}return n.reset=async()=>{const s=t;t=void 0,s&&await s},n}function Wl(e,t=200,n={}){return Hl(Ul(t,n),e)}const xn=ds?window:void 0,hs=ds?window.navigator:void 0;function ps(e){var t;const n=Be(e);return(t=n==null?void 0:n.$el)!=null?t:n}function gs(...e){let t,n,s,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,s,r]=e,t=xn):[t,n,s,r]=e,!t)return Gn;Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(f=>f()),i.length=0},l=(f,h,v,g)=>(f.addEventListener(h,v,g),()=>f.removeEventListener(h,v,g)),c=xe(()=>[ps(t),Be(r)],([f,h])=>{if(o(),!f)return;const v=$l(h)?{...h}:h;i.push(...n.flatMap(g=>s.map(T=>l(f,g,T,v))))},{immediate:!0,flush:"post"}),d=()=>{c(),o()};return yn(d),d}function Bl(){const e=q(!1),t=oi();return t&&cs(()=>{e.value=!0},t),e}function wn(e){const t=Bl();return Je(()=>(t.value,!!e()))}function Kl(e,t,n={}){const{window:s=xn,...r}=n;let i;const o=wn(()=>s&&"MutationObserver"in s),l=()=>{i&&(i.disconnect(),i=void 0)},c=Je(()=>{const v=Be(e),g=(Array.isArray(v)?v:[v]).map(ps).filter(Ll);return new Set(g)}),d=xe(()=>c.value,v=>{l(),o.value&&v.size&&(i=new MutationObserver(t),v.forEach(g=>i.observe(g,r)))},{immediate:!0,flush:"post"}),f=()=>i==null?void 0:i.takeRecords(),h=()=>{d(),l()};return yn(h),{isSupported:o,stop:h,takeRecords:f}}function ql(e,t={}){const{controls:n=!1,navigator:s=hs}=t,r=wn(()=>s&&"permissions"in s),i=Xt(),o={name:e},l=Xt(),c=()=>{var f,h;l.value=(h=(f=i.value)==null?void 0:f.state)!=null?h:"prompt"};gs(i,"change",c);const d=kl(async()=>{if(r.value){if(!i.value)try{i.value=await s.permissions.query(o)}catch{i.value=void 0}finally{c()}if(n)return L(i.value)}});return d(),n?{state:l,isSupported:r,query:d}:l}function Kt(e,t,n={}){const{window:s=xn,initialValue:r,observe:i=!1}=n,o=q(r),l=Je(()=>{var d;return ps(t)||((d=s==null?void 0:s.document)==null?void 0:d.documentElement)});function c(){var d;const f=Be(e),h=Be(l);if(h&&s&&f){const v=(d=s.getComputedStyle(h).getPropertyValue(f))==null?void 0:d.trim();o.value=v||r}}return i&&Kl(l,c,{attributeFilter:["style","class"],window:s}),xe([l,()=>Be(e)],(d,f)=>{f[0]&&f[1]&&f[0].style.removeProperty(f[1]),c()},{immediate:!0}),xe(o,d=>{var f;const h=Be(e);(f=l.value)!=null&&f.style&&h&&(d==null?l.value.style.removeProperty(h):l.value.style.setProperty(h,d))}),o}function Gl(e={}){const{navigator:t=hs,requestPermissions:n=!1,constraints:s={audio:!0,video:!0},onUpdated:r}=e,i=q([]),o=Je(()=>i.value.filter(T=>T.kind==="videoinput")),l=Je(()=>i.value.filter(T=>T.kind==="audioinput")),c=Je(()=>i.value.filter(T=>T.kind==="audiooutput")),d=wn(()=>t&&t.mediaDevices&&t.mediaDevices.enumerateDevices),f=q(!1);let h;async function v(){d.value&&(i.value=await t.mediaDevices.enumerateDevices(),r==null||r(i.value),h&&(h.getTracks().forEach(T=>T.stop()),h=null))}async function g(){if(!d.value)return!1;if(f.value)return!0;const{state:T,query:A}=ql("camera",{controls:!0});if(await A(),T.value!=="granted"){let H=!0;try{h=await t.mediaDevices.getUserMedia(s)}catch{h=null,H=!1}v(),f.value=H}else f.value=!0;return f.value}return d.value&&(n&&g(),gs(t.mediaDevices,"devicechange",v),v()),{devices:i,ensurePermissions:g,permissionGranted:f,videoInputs:o,audioInputs:l,audioOutputs:c,isSupported:d}}const Ys="--vueuse-safe-area-top",Xs="--vueuse-safe-area-right",Zs="--vueuse-safe-area-bottom",Qs="--vueuse-safe-area-left";function zl(){const e=q(""),t=q(""),n=q(""),s=q("");if(ds){const i=Kt(Ys),o=Kt(Xs),l=Kt(Zs),c=Kt(Qs);i.value="env(safe-area-inset-top, 0px)",o.value="env(safe-area-inset-right, 0px)",l.value="env(safe-area-inset-bottom, 0px)",c.value="env(safe-area-inset-left, 0px)",r(),gs("resize",Wl(r))}function r(){e.value=qt(Ys),t.value=qt(Xs),n.value=qt(Zs),s.value=qt(Qs)}return{top:e,right:t,bottom:n,left:s,update:r}}function qt(e){return getComputedStyle(document.documentElement).getPropertyValue(e)}function Jl(e={}){var t,n;const s=q((t=e.enabled)!=null?t:!1),r=q((n=e.autoSwitch)!=null?n:!0),i=q(e.constraints),{navigator:o=hs}=e,l=wn(()=>{var A;return(A=o==null?void 0:o.mediaDevices)==null?void 0:A.getUserMedia}),c=Xt();function d(A){switch(A){case"video":{if(i.value)return i.value.video||!1;break}case"audio":{if(i.value)return i.value.audio||!1;break}}}async function f(){if(!(!l.value||c.value))return c.value=await o.mediaDevices.getUserMedia({video:d("video"),audio:d("audio")}),c.value}function h(){var A;(A=c.value)==null||A.getTracks().forEach(H=>H.stop()),c.value=void 0}function v(){h(),s.value=!1}async function g(){return await f(),c.value&&(s.value=!0),c.value}async function T(){return h(),await g()}return xe(s,A=>{A?f():h()},{immediate:!0}),xe(i,()=>{r.value&&c.value&&T()},{immediate:!0}),yn(()=>{v()}),{isSupported:l,stream:c,start:g,stop:v,restart:T,constraints:i,enabled:s,autoSwitch:r}}function Yl(e,t,n){const{window:s=xn}={},r=q(null),i=Xt(),o=(...c)=>{i.value&&i.value.postMessage(...c)},l=function(){i.value&&i.value.terminate()};return s&&(i.value=new Worker(e,t),i.value.onmessage=c=>{r.value=c.data},yn(()=>{i.value&&i.value.terminate()})),{data:r,post:o,terminate:l,worker:i}}const Xl=pn({__name:"AudioVisualizer",props:{stream:{}},setup(e){const t=e,n=q(!1),s=q();cs(()=>{r()}),xe(()=>t.stream,()=>{r()});function r(){if(n.value||!s.value||!t.stream)return;n.value=!0;const i=new(window.AudioContext||window.webkitAudioContext),o=i.createMediaStreamSource(t.stream),l=i.createAnalyser();l.fftSize=2048,o.connect(l);const c=l.frequencyBinCount,d=new Uint8Array(c),f=()=>{try{if(!s.value)return;requestAnimationFrame(f),l.getByteTimeDomainData(d);const h=s.value.getContext("2d");if(!h)return;h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,s.value.width,s.value.height),h.lineWidth=2,h.strokeStyle="rgb(0, 0, 0)",h.beginPath();const v=s.value.width*1/c;let g=0;for(let T=0;T<c;++T){const H=d[T]/128*s.value.height/2;T===0?h.moveTo(g,H):h.lineTo(g,H),g+=v}h.lineTo(s.value.width,s.value.height/2),h.stroke()}catch(h){console.error(h)}};f()}return(i,o)=>(ee(),ne("canvas",{ref_key:"canvasRef",ref:s,width:"720",height:"240"},null,512))}}),Zl={className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5"},Ql=pn({__name:"Progress",props:{text:{},percentage:{default:0},total:{}},setup(e){function t(n){n||(n=0);const s=n===0?0:Math.floor(Math.log(n)/Math.log(1024));return+(n/1024**s).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}return(n,s)=>(ee(),ne("div",Zl,[k("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:Lt({width:`${n.percentage}%`})},We(n.text)+" ("+We(n.percentage.toFixed(2))+"%"+We(Number.isNaN(n.total)?"":` of ${t(n.total)}`)+") ",5)]))}}),ec=["value"],tc=pn({__name:"WhisperLanguageSelect",props:{modelValue:{type:String},modelModifiers:{}},emits:["update:modelValue"],setup(e){const t=qo(e,"modelValue"),n={en:"english",zh:"chinese",de:"german",es:"spanish/castilian",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan/valencian",nl:"dutch/flemish",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian/moldavian/moldovan",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi/panjabi",si:"sinhala/sinhalese",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole/haitian",ps:"pashto/pushto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish/letzeburgesch",my:"myanmar/burmese",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese"};function s(i){return i=i.toLowerCase(),(i.match(/\w+.?/g)||[]).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}const r=Object.values(n).map(s);return(i,o)=>(ee(),ne("div",null,[Fr(k("select",{"onUpdate:modelValue":o[0]||(o[0]=l=>t.value=l),className:"border rounded-lg p-2 max-w-[100px]"},[(ee(!0),ne(be,null,Hn(Object.keys(n),(l,c)=>(ee(),ne("option",{key:c,value:l},We(Fe(r)[c]),9,ec))),128))],512),[[ai,t.value]])]))}}),nc="/assets/worker-DdCDtwuX.js",sc={"h-full":"","w-full":""},rc={key:0,class:"mx-auto h-screen flex flex-col justify-end bg-white text-gray-800 dark:bg-gray-900 dark:text-gray-200"},ic={class:"scrollbar-thin relative h-full flex flex-col items-center justify-center overflow-auto"},oc={class:"flex flex-col items-center px-4"},lc=["disabled"],cc={class:"w-[500px] p-2"},uc={key:0,class:"relative"},fc={class:"overflow-wrap-anywhere white h-[80px] w-full overflow-y-auto border rounded-lg p-2"},ac={key:0,class:"absolute bottom-0 right-0 px-1"},dc={key:1,class:"relative w-full flex justify-center"},hc={key:2,class:"relative w-full flex flex-col justify-center"},pc=["value"],gc={key:3,class:"mx-auto max-w-[500px] w-full p-4 text-left"},mc={class:"text-center"},vc={key:1,class:"fixed z-10 h-screen w-screen flex items-center justify-center bg-black bg-opacity-[92%] text-center text-2xl text-white font-semibold"},er=16e3,bc=30,_c=pn({__name:"App",setup(e){const t="gpu"in navigator&&!navigator.gpu,n=er*bc,{top:s,right:r,bottom:i,left:o}=zl(),l=q(null),c=q(""),d=q([]),f=q(""),h=q(),v=q("en"),g=q(),T=q(!1),A=q(!1),H=q([]),N=q(null),{post:G,data:J}=Yl(nc,{type:"module"}),{audioInputs:P}=Gl({constraints:{audio:!0},requestPermissions:!0}),Y=q(),Ae=Je(()=>({audio:{deviceId:Y.value}})),{stream:ce}=Jl({constraints:Ae,enabled:!0,autoSwitch:!0});xe(J,j=>{var D,X;switch(j.status){case"loading":l.value="loading",c.value=j.data;break;case"initiate":d.value.push(j);break;case"progress":d.value=d.value.map(de=>de.file===j.file?{...de,...j}:de);break;case"done":d.value=d.value.filter(de=>de.file!==j.file);break;case"ready":l.value="ready",(D=g.value)==null||D.start();break;case"start":A.value=!0,(X=g.value)==null||X.requestData();break;case"update":h.value=j.tps;break;case"complete":A.value=!1,f.value=j.output[0]||"";break}}),xe(ce,()=>{ce.value&&(g.value=new MediaRecorder(ce.value),N.value=new AudioContext({sampleRate:er}),g.value.onstart=()=>{T.value=!0,H.value=[]},g.value.ondataavailable=j=>{j.data.size>0?H.value.push(j.data):setTimeout(()=>{var D;(D=g.value)==null||D.requestData()},25)},g.value.onstop=()=>{T.value=!1})}),Wo(()=>{var j;if(g.value&&T.value&&!A.value&&l.value==="ready")if(H.value.length>0){const D=new Blob(H.value,{type:g.value.mimeType}),X=new FileReader;X.onloadend=async()=>{var te;const de=X.result,Qe=await((te=N.value)==null?void 0:te.decodeAudioData(de));let Se=Qe==null?void 0:Qe.getChannelData(0);((Se==null?void 0:Se.length)||0)>n&&(Se=Se==null?void 0:Se.slice(-n)),G({type:"generate",data:{audio:Se,language:v.value}})},X.readAsArrayBuffer(D)}else(j=g.value)==null||j.requestData()}),xe([v],()=>{var j,D;(j=g.value)==null||j.stop(),(D=g.value)==null||D.start()});function Ee(){G({type:"load"}),l.value="loading"}function ut(){var j,D;(j=g.value)==null||j.stop(),(D=g.value)==null||D.start()}return us(()=>{var j;(j=g.value)==null||j.stop(),g.value=void 0}),(j,D)=>(ee(),ne("main",{text:"gray-700 dark:gray-200","h-full":"","font-sans":"",style:Lt({paddingTop:`${Fe(s)}px`,paddingRight:`${Fe(r)}px`,paddingBottom:`${Fe(i)}px`,paddingLeft:`${Fe(o)}px`})},[k("div",sc,[Fe(t)?(ee(),ne("div",rc,[k("div",ic,[D[6]||(D[6]=k("div",{class:"mb-1 max-w-[400px] flex flex-col items-center text-center"},[k("img",{src:Nl,width:"50%",height:"auto",class:"block"}),k("h1",{class:"mb-1 text-4xl font-bold"}," Whisper WebGPU "),k("h2",{class:"text-xl font-semibold"}," Real-time in-browser speech recognition ")],-1)),k("div",oc,[l.value===null?(ee(),ne(be,{key:0},[D[3]||(D[3]=k("p",{class:"mb-4 max-w-[480px]"},[k("br"),it(" You are about to load "),k("a",{href:"https://huggingface.co/onnx-community/whisper-base",target:"_blank",rel:"noreferrer",class:"font-medium underline"},"whisper-base"),it(", a 73 million parameter speech recognition model that is optimized for inference on the web. Once downloaded, the model (~200 MB) will be cached and reused when you revisit the page."),k("br"),k("br"),it(" Everything runs directly in your browser using "),k("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",class:"underline"},"🤗 Transformers.js"),it(" and ONNX Runtime Web, meaning no data is sent to a server. You can even disconnect from the internet after the model has loaded! ")],-1)),k("button",{class:"select-none border rounded-lg bg-blue-400 px-4 py-2 text-white disabled:cursor-not-allowed disabled:bg-blue-100 hover:bg-blue-500",disabled:l.value!==null,onClick:Ee},D[2]||(D[2]=[k("span",null,"Load model",-1)]),8,lc)],64)):at("",!0),k("div",cc,[Te(Xl,{class:"w-full rounded-lg",stream:Fe(ce)},null,8,["stream"]),l.value==="ready"?(ee(),ne("div",uc,[k("p",fc,We(f.value),1),h.value?(ee(),ne("span",ac,We(h.value.toFixed(2))+" tok/s",1)):at("",!0)])):at("",!0)]),l.value==="ready"?(ee(),ne("div",dc,[Te(tc,{modelValue:v.value,"onUpdate:modelValue":D[0]||(D[0]=X=>v.value=X)},null,8,["modelValue"]),k("button",{class:"absolute right-2 border rounded-lg px-2",onClick:ut},D[4]||(D[4]=[k("span",null,"Reset",-1)]))])):at("",!0),l.value==="ready"?(ee(),ne("div",hc,[Fr(k("select",{"onUpdate:modelValue":D[1]||(D[1]=X=>Y.value=X),className:"border rounded-lg p-2 max-w-[100px]"},[D[5]||(D[5]=k("option",{disabled:""}," Select a Audio Input ",-1)),(ee(!0),ne(be,null,Hn(Fe(P),X=>(ee(),ne("option",{key:X.deviceId,value:X.deviceId},We(X.label),9,pc))),128))],512),[[ai,Y.value]])])):at("",!0),l.value==="loading"?(ee(),ne("div",gc,[k("p",mc,We(c.value),1),(ee(!0),ne(be,null,Hn(d.value,(X,de)=>(ee(),si(Ql,{key:de,text:X.file,percentage:X.progress||0,total:X.total||0},null,8,["text","percentage","total"]))),128))])):at("",!0)])])])):(ee(),ne("div",vc,D[7]||(D[7]=[it(" WebGPU is not supported"),k("br",null,null,-1),it("by this browser :( ")])))])],4))}});Dl(_c).mount("#app");
 
14
  * @vue/runtime-dom v3.5.13
15
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
16
  * @license MIT
17
+ **/let qn;const Ns=typeof window<"u"&&window.trustedTypes;if(Ns)try{qn=Ns.createPolicy("vue",{createHTML:e=>e})}catch{}const ui=qn?e=>qn.createHTML(e):e=>e,dl="http://www.w3.org/2000/svg",hl="http://www.w3.org/1998/Math/MathML",He=typeof document<"u"?document:null,Ls=He&&He.createElement("template"),pl={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?He.createElementNS(dl,e):t==="mathml"?He.createElementNS(hl,e):n?He.createElement(e,{is:n}):He.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>He.createTextNode(e),createComment:e=>He.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>He.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,i){const o=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{Ls.innerHTML=ui(s==="svg"?`<svg>${e}</svg>`:s==="mathml"?`<math>${e}</math>`:e);const l=Ls.content;if(s==="svg"||s==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},gl=Symbol("_vtc");function ml(e,t,n){const s=e[gl];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Vs=Symbol("_vod"),vl=Symbol("_vsh"),bl=Symbol(""),_l=/(^|;)\s*display\s*:/;function yl(e,t,n){const s=e.style,r=Q(n);let i=!1;if(n&&!r){if(t)if(Q(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();n[l]==null&&Yt(s,l,"")}else for(const o in t)n[o]==null&&Yt(s,o,"");for(const o in n)o==="display"&&(i=!0),Yt(s,o,n[o])}else if(r){if(t!==n){const o=s[bl];o&&(n+=";"+o),s.cssText=n,i=_l.test(n)}}else t&&e.removeAttribute("style");Vs in e&&(e[Vs]=i?s.display:"",e[vl]&&(s.display="none"))}const $s=/\s*!important$/;function Yt(e,t,n){if(M(n))n.forEach(s=>Yt(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=xl(e,t);$s.test(n)?e.setProperty(Ye(s),n.replace($s,""),"important"):e[s]=n}}const Hs=["Webkit","Moz","ms"],In={};function xl(e,t){const n=In[t];if(n)return n;let s=Ke(t);if(s!=="filter"&&s in e)return In[t]=s;s=rr(s);for(let r=0;r<Hs.length;r++){const i=Hs[r]+s;if(i in e)return In[t]=i}return t}const Us="http://www.w3.org/1999/xlink";function ks(e,t,n,s,r,i=Ci(t)){s&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(Us,t.slice(6,t.length)):e.setAttributeNS(Us,t,n):n==null||i&&!lr(n)?e.removeAttribute(t):e.setAttribute(t,i?"":Le(n)?String(n):n)}function Ws(e,t,n,s,r){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?ui(n):n);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const l=i==="OPTION"?e.getAttribute("value")||"":e.value,c=n==null?e.type==="checkbox"?"on":"":String(n);(l!==c||!("_value"in e))&&(e.value=c),n==null&&e.removeAttribute(t),e._value=n;return}let o=!1;if(n===""||n==null){const l=typeof e[t];l==="boolean"?n=lr(n):n==null&&l==="string"?(n="",o=!0):l==="number"&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(r||t)}function fi(e,t,n,s){e.addEventListener(t,n,s)}function wl(e,t,n,s){e.removeEventListener(t,n,s)}const Bs=Symbol("_vei");function Sl(e,t,n,s,r=null){const i=e[Bs]||(e[Bs]={}),o=i[t];if(s&&o)o.value=s;else{const[l,c]=Cl(t);if(s){const d=i[t]=El(s,r);fi(e,l,d,c)}else o&&(wl(e,l,o,c),i[t]=void 0)}}const Ks=/(?:Once|Passive|Capture)$/;function Cl(e){let t;if(Ks.test(e)){t={};let s;for(;s=e.match(Ks);)e=e.slice(0,e.length-s[0].length),t[s[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):Ye(e.slice(2)),t]}let Dn=0;const Tl=Promise.resolve(),Al=()=>Dn||(Tl.then(()=>Dn=0),Dn=Date.now());function El(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;Ve(Ol(s,n.value),t,5,[s])};return n.value=e,n.attached=Al(),n}function Ol(e,t){if(M(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const qs=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Pl=(e,t,n,s,r,i)=>{const o=r==="svg";t==="class"?ml(e,s,o):t==="style"?yl(e,n,s):on(t)?Jn(t)||Sl(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Ml(e,t,s,o))?(Ws(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ks(e,t,s,o,i,t!=="value")):e._isVueCE&&(/[A-Z]/.test(t)||!Q(s))?Ws(e,Ke(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),ks(e,t,s,o))};function Ml(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&qs(t)&&I(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return qs(t)&&Q(n)?!1:t in e}const Gs=e=>{const t=e.props["onUpdate:modelValue"]||!1;return M(t)?n=>Gt(t,n):t},Fn=Symbol("_assign"),ai={deep:!0,created(e,{value:t,modifiers:{number:n}},s){const r=ln(t);fi(e,"change",()=>{const i=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?or(rn(o)):rn(o));e[Fn](e.multiple?r?new Set(i):i:i[0]),e._assigning=!0,Pr(()=>{e._assigning=!1})}),e[Fn]=Gs(s)},mounted(e,{value:t}){zs(e,t)},beforeUpdate(e,t,n){e[Fn]=Gs(n)},updated(e,{value:t}){e._assigning||zs(e,t)}};function zs(e,t){const n=e.multiple,s=M(t);if(!(n&&!s&&!ln(t))){for(let r=0,i=e.options.length;r<i;r++){const o=e.options[r],l=rn(o);if(n)if(s){const c=typeof l;c==="string"||c==="number"?o.selected=t.some(d=>String(d)===String(l)):o.selected=Ai(t,l)>-1}else o.selected=t.has(l);else if(fn(rn(o),t)){e.selectedIndex!==r&&(e.selectedIndex=r);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function rn(e){return"_value"in e?e._value:e.value}const Rl=le({patchProp:Pl},pl);let Js;function Il(){return Js||(Js=Lo(Rl))}const Dl=(...e)=>{const t=Il().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=jl(s);if(!r)return;const i=t._component;!I(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=n(r,!1,Fl(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t};function Fl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function jl(e){return Q(e)?document.querySelector(e):e}const Nl="/logo.png";function yn(e){return fr()?(Oi(e),!0):!1}function Be(e){return typeof e=="function"?e():Fe(e)}const ds=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ll=e=>e!=null,Vl=Object.prototype.toString,$l=e=>Vl.call(e)==="[object Object]",Gn=()=>{};function Hl(e,t){function n(...s){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,s),{fn:t,thisArg:this,args:s})).then(r).catch(i)})}return n}function Ul(e,t={}){let n,s,r=Gn;const i=l=>{clearTimeout(l),r(),r=Gn};return l=>{const c=Be(e),d=Be(t.maxWait);return n&&i(n),c<=0||d!==void 0&&d<=0?(s&&(i(s),s=null),Promise.resolve(l())):new Promise((f,h)=>{r=t.rejectOnCancel?h:f,d&&!s&&(s=setTimeout(()=>{n&&i(n),s=null,f(l())},d)),n=setTimeout(()=>{s&&i(s),s=null,f(l())},c)})}}function kl(e){let t;function n(){return t||(t=e()),t}return n.reset=async()=>{const s=t;t=void 0,s&&await s},n}function Wl(e,t=200,n={}){return Hl(Ul(t,n),e)}const xn=ds?window:void 0,hs=ds?window.navigator:void 0;function ps(e){var t;const n=Be(e);return(t=n==null?void 0:n.$el)!=null?t:n}function gs(...e){let t,n,s,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,s,r]=e,t=xn):[t,n,s,r]=e,!t)return Gn;Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(f=>f()),i.length=0},l=(f,h,v,g)=>(f.addEventListener(h,v,g),()=>f.removeEventListener(h,v,g)),c=xe(()=>[ps(t),Be(r)],([f,h])=>{if(o(),!f)return;const v=$l(h)?{...h}:h;i.push(...n.flatMap(g=>s.map(T=>l(f,g,T,v))))},{immediate:!0,flush:"post"}),d=()=>{c(),o()};return yn(d),d}function Bl(){const e=q(!1),t=oi();return t&&cs(()=>{e.value=!0},t),e}function wn(e){const t=Bl();return Je(()=>(t.value,!!e()))}function Kl(e,t,n={}){const{window:s=xn,...r}=n;let i;const o=wn(()=>s&&"MutationObserver"in s),l=()=>{i&&(i.disconnect(),i=void 0)},c=Je(()=>{const v=Be(e),g=(Array.isArray(v)?v:[v]).map(ps).filter(Ll);return new Set(g)}),d=xe(()=>c.value,v=>{l(),o.value&&v.size&&(i=new MutationObserver(t),v.forEach(g=>i.observe(g,r)))},{immediate:!0,flush:"post"}),f=()=>i==null?void 0:i.takeRecords(),h=()=>{d(),l()};return yn(h),{isSupported:o,stop:h,takeRecords:f}}function ql(e,t={}){const{controls:n=!1,navigator:s=hs}=t,r=wn(()=>s&&"permissions"in s),i=Xt(),o={name:e},l=Xt(),c=()=>{var f,h;l.value=(h=(f=i.value)==null?void 0:f.state)!=null?h:"prompt"};gs(i,"change",c);const d=kl(async()=>{if(r.value){if(!i.value)try{i.value=await s.permissions.query(o)}catch{i.value=void 0}finally{c()}if(n)return L(i.value)}});return d(),n?{state:l,isSupported:r,query:d}:l}function Kt(e,t,n={}){const{window:s=xn,initialValue:r,observe:i=!1}=n,o=q(r),l=Je(()=>{var d;return ps(t)||((d=s==null?void 0:s.document)==null?void 0:d.documentElement)});function c(){var d;const f=Be(e),h=Be(l);if(h&&s&&f){const v=(d=s.getComputedStyle(h).getPropertyValue(f))==null?void 0:d.trim();o.value=v||r}}return i&&Kl(l,c,{attributeFilter:["style","class"],window:s}),xe([l,()=>Be(e)],(d,f)=>{f[0]&&f[1]&&f[0].style.removeProperty(f[1]),c()},{immediate:!0}),xe(o,d=>{var f;const h=Be(e);(f=l.value)!=null&&f.style&&h&&(d==null?l.value.style.removeProperty(h):l.value.style.setProperty(h,d))}),o}function Gl(e={}){const{navigator:t=hs,requestPermissions:n=!1,constraints:s={audio:!0,video:!0},onUpdated:r}=e,i=q([]),o=Je(()=>i.value.filter(T=>T.kind==="videoinput")),l=Je(()=>i.value.filter(T=>T.kind==="audioinput")),c=Je(()=>i.value.filter(T=>T.kind==="audiooutput")),d=wn(()=>t&&t.mediaDevices&&t.mediaDevices.enumerateDevices),f=q(!1);let h;async function v(){d.value&&(i.value=await t.mediaDevices.enumerateDevices(),r==null||r(i.value),h&&(h.getTracks().forEach(T=>T.stop()),h=null))}async function g(){if(!d.value)return!1;if(f.value)return!0;const{state:T,query:A}=ql("camera",{controls:!0});if(await A(),T.value!=="granted"){let H=!0;try{h=await t.mediaDevices.getUserMedia(s)}catch{h=null,H=!1}v(),f.value=H}else f.value=!0;return f.value}return d.value&&(n&&g(),gs(t.mediaDevices,"devicechange",v),v()),{devices:i,ensurePermissions:g,permissionGranted:f,videoInputs:o,audioInputs:l,audioOutputs:c,isSupported:d}}const Ys="--vueuse-safe-area-top",Xs="--vueuse-safe-area-right",Zs="--vueuse-safe-area-bottom",Qs="--vueuse-safe-area-left";function zl(){const e=q(""),t=q(""),n=q(""),s=q("");if(ds){const i=Kt(Ys),o=Kt(Xs),l=Kt(Zs),c=Kt(Qs);i.value="env(safe-area-inset-top, 0px)",o.value="env(safe-area-inset-right, 0px)",l.value="env(safe-area-inset-bottom, 0px)",c.value="env(safe-area-inset-left, 0px)",r(),gs("resize",Wl(r))}function r(){e.value=qt(Ys),t.value=qt(Xs),n.value=qt(Zs),s.value=qt(Qs)}return{top:e,right:t,bottom:n,left:s,update:r}}function qt(e){return getComputedStyle(document.documentElement).getPropertyValue(e)}function Jl(e={}){var t,n;const s=q((t=e.enabled)!=null?t:!1),r=q((n=e.autoSwitch)!=null?n:!0),i=q(e.constraints),{navigator:o=hs}=e,l=wn(()=>{var A;return(A=o==null?void 0:o.mediaDevices)==null?void 0:A.getUserMedia}),c=Xt();function d(A){switch(A){case"video":{if(i.value)return i.value.video||!1;break}case"audio":{if(i.value)return i.value.audio||!1;break}}}async function f(){if(!(!l.value||c.value))return c.value=await o.mediaDevices.getUserMedia({video:d("video"),audio:d("audio")}),c.value}function h(){var A;(A=c.value)==null||A.getTracks().forEach(H=>H.stop()),c.value=void 0}function v(){h(),s.value=!1}async function g(){return await f(),c.value&&(s.value=!0),c.value}async function T(){return h(),await g()}return xe(s,A=>{A?f():h()},{immediate:!0}),xe(i,()=>{r.value&&c.value&&T()},{immediate:!0}),yn(()=>{v()}),{isSupported:l,stream:c,start:g,stop:v,restart:T,constraints:i,enabled:s,autoSwitch:r}}function Yl(e,t,n){const{window:s=xn}={},r=q(null),i=Xt(),o=(...c)=>{i.value&&i.value.postMessage(...c)},l=function(){i.value&&i.value.terminate()};return s&&(i.value=new Worker(e,t),i.value.onmessage=c=>{r.value=c.data},yn(()=>{i.value&&i.value.terminate()})),{data:r,post:o,terminate:l,worker:i}}const Xl=pn({__name:"AudioVisualizer",props:{stream:{}},setup(e){const t=e,n=q(!1),s=q();cs(()=>{r()}),xe(()=>t.stream,()=>{r()});function r(){if(n.value||!s.value||!t.stream)return;n.value=!0;const i=new(window.AudioContext||window.webkitAudioContext),o=i.createMediaStreamSource(t.stream),l=i.createAnalyser();l.fftSize=2048,o.connect(l);const c=l.frequencyBinCount,d=new Uint8Array(c),f=()=>{try{if(!s.value)return;requestAnimationFrame(f),l.getByteTimeDomainData(d);const h=s.value.getContext("2d");if(!h)return;h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,s.value.width,s.value.height),h.lineWidth=2,h.strokeStyle="rgb(0, 0, 0)",h.beginPath();const v=s.value.width*1/c;let g=0;for(let T=0;T<c;++T){const H=d[T]/128*s.value.height/2;T===0?h.moveTo(g,H):h.lineTo(g,H),g+=v}h.lineTo(s.value.width,s.value.height/2),h.stroke()}catch(h){console.error(h)}};f()}return(i,o)=>(ee(),ne("canvas",{ref_key:"canvasRef",ref:s,width:"720",height:"240"},null,512))}}),Zl={className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5"},Ql=pn({__name:"Progress",props:{text:{},percentage:{default:0},total:{}},setup(e){function t(n){n||(n=0);const s=n===0?0:Math.floor(Math.log(n)/Math.log(1024));return+(n/1024**s).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}return(n,s)=>(ee(),ne("div",Zl,[k("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:Lt({width:`${n.percentage}%`})},We(n.text)+" ("+We(n.percentage.toFixed(2))+"%"+We(Number.isNaN(n.total)?"":` of ${t(n.total)}`)+") ",5)]))}}),ec=["value"],tc=pn({__name:"WhisperLanguageSelect",props:{modelValue:{type:String},modelModifiers:{}},emits:["update:modelValue"],setup(e){const t=qo(e,"modelValue"),n={en:"english",zh:"chinese",de:"german",es:"spanish/castilian",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan/valencian",nl:"dutch/flemish",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian/moldavian/moldovan",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi/panjabi",si:"sinhala/sinhalese",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole/haitian",ps:"pashto/pushto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish/letzeburgesch",my:"myanmar/burmese",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese"};function s(i){return i=i.toLowerCase(),(i.match(/\w+.?/g)||[]).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}const r=Object.values(n).map(s);return(i,o)=>(ee(),ne("div",null,[Fr(k("select",{"onUpdate:modelValue":o[0]||(o[0]=l=>t.value=l),className:"border rounded-lg p-2 max-w-[100px]"},[(ee(!0),ne(be,null,Hn(Object.keys(n),(l,c)=>(ee(),ne("option",{key:c,value:l},We(Fe(r)[c]),9,ec))),128))],512),[[ai,t.value]])]))}}),nc="/assets/worker-DdCDtwuX.js",sc={"h-full":"","w-full":""},rc={key:0,class:"mx-auto h-screen flex flex-col justify-end bg-white text-gray-800 dark:bg-gray-900 dark:text-gray-200"},ic={class:"scrollbar-thin relative h-full flex flex-col items-center justify-center overflow-auto"},oc={class:"flex flex-col items-center px-4"},lc=["disabled"],cc={class:"w-[500px] p-2"},uc={key:0,class:"relative"},fc={class:"overflow-wrap-anywhere white h-[80px] w-full overflow-y-auto border rounded-lg p-2"},ac={key:0,class:"absolute bottom-0 right-0 px-1"},dc={key:1,class:"relative w-full flex justify-center"},hc={key:2,class:"relative w-full flex flex-col justify-center"},pc=["value"],gc={key:3,class:"mx-auto max-w-[500px] w-full p-4 text-left"},mc={class:"text-center"},vc={key:1,class:"fixed z-10 h-screen w-screen flex items-center justify-center bg-black bg-opacity-[92%] text-center text-2xl text-white font-semibold"},er=16e3,bc=30,_c=pn({__name:"App",setup(e){const t="gpu"in navigator&&navigator.gpu,n=er*bc,{top:s,right:r,bottom:i,left:o}=zl(),l=q(null),c=q(""),d=q([]),f=q(""),h=q(),v=q("en"),g=q(),T=q(!1),A=q(!1),H=q([]),N=q(null),{post:G,data:J}=Yl(nc,{type:"module"}),{audioInputs:P}=Gl({constraints:{audio:!0},requestPermissions:!0}),Y=q(),Ae=Je(()=>({audio:{deviceId:Y.value}})),{stream:ce}=Jl({constraints:Ae,enabled:!0,autoSwitch:!0});xe(J,j=>{var D,X;switch(j.status){case"loading":l.value="loading",c.value=j.data;break;case"initiate":d.value.push(j);break;case"progress":d.value=d.value.map(de=>de.file===j.file?{...de,...j}:de);break;case"done":d.value=d.value.filter(de=>de.file!==j.file);break;case"ready":l.value="ready",(D=g.value)==null||D.start();break;case"start":A.value=!0,(X=g.value)==null||X.requestData();break;case"update":h.value=j.tps;break;case"complete":A.value=!1,f.value=j.output[0]||"";break}}),xe(ce,()=>{ce.value&&(g.value=new MediaRecorder(ce.value),N.value=new AudioContext({sampleRate:er}),g.value.onstart=()=>{T.value=!0,H.value=[]},g.value.ondataavailable=j=>{j.data.size>0?H.value.push(j.data):setTimeout(()=>{var D;(D=g.value)==null||D.requestData()},25)},g.value.onstop=()=>{T.value=!1})}),Wo(()=>{var j;if(g.value&&T.value&&!A.value&&l.value==="ready")if(H.value.length>0){const D=new Blob(H.value,{type:g.value.mimeType}),X=new FileReader;X.onloadend=async()=>{var te;const de=X.result,Qe=await((te=N.value)==null?void 0:te.decodeAudioData(de));let Se=Qe==null?void 0:Qe.getChannelData(0);((Se==null?void 0:Se.length)||0)>n&&(Se=Se==null?void 0:Se.slice(-n)),G({type:"generate",data:{audio:Se,language:v.value}})},X.readAsArrayBuffer(D)}else(j=g.value)==null||j.requestData()}),xe([v],()=>{var j,D;(j=g.value)==null||j.stop(),(D=g.value)==null||D.start()});function Ee(){G({type:"load"}),l.value="loading"}function ut(){var j,D;(j=g.value)==null||j.stop(),(D=g.value)==null||D.start()}return us(()=>{var j;(j=g.value)==null||j.stop(),g.value=void 0}),(j,D)=>(ee(),ne("main",{text:"gray-700 dark:gray-200","h-full":"","font-sans":"",style:Lt({paddingTop:`${Fe(s)}px`,paddingRight:`${Fe(r)}px`,paddingBottom:`${Fe(i)}px`,paddingLeft:`${Fe(o)}px`})},[k("div",sc,[Fe(t)?(ee(),ne("div",rc,[k("div",ic,[D[6]||(D[6]=k("div",{class:"mb-1 max-w-[400px] flex flex-col items-center text-center"},[k("img",{src:Nl,width:"50%",height:"auto",class:"block"}),k("h1",{class:"mb-1 text-4xl font-bold"}," Whisper WebGPU "),k("h2",{class:"text-xl font-semibold"}," Real-time in-browser speech recognition ")],-1)),k("div",oc,[l.value===null?(ee(),ne(be,{key:0},[D[3]||(D[3]=k("p",{class:"mb-4 max-w-[480px]"},[k("br"),it(" You are about to load "),k("a",{href:"https://huggingface.co/onnx-community/whisper-base",target:"_blank",rel:"noreferrer",class:"font-medium underline"},"whisper-base"),it(", a 73 million parameter speech recognition model that is optimized for inference on the web. Once downloaded, the model (~200 MB) will be cached and reused when you revisit the page."),k("br"),k("br"),it(" Everything runs directly in your browser using "),k("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",class:"underline"},"🤗 Transformers.js"),it(" and ONNX Runtime Web, meaning no data is sent to a server. You can even disconnect from the internet after the model has loaded! ")],-1)),k("button",{class:"select-none border rounded-lg bg-blue-400 px-4 py-2 text-white disabled:cursor-not-allowed disabled:bg-blue-100 hover:bg-blue-500",disabled:l.value!==null,onClick:Ee},D[2]||(D[2]=[k("span",null,"Load model",-1)]),8,lc)],64)):at("",!0),k("div",cc,[Te(Xl,{class:"w-full rounded-lg",stream:Fe(ce)},null,8,["stream"]),l.value==="ready"?(ee(),ne("div",uc,[k("p",fc,We(f.value),1),h.value?(ee(),ne("span",ac,We(h.value.toFixed(2))+" tok/s",1)):at("",!0)])):at("",!0)]),l.value==="ready"?(ee(),ne("div",dc,[Te(tc,{modelValue:v.value,"onUpdate:modelValue":D[0]||(D[0]=X=>v.value=X)},null,8,["modelValue"]),k("button",{class:"absolute right-2 border rounded-lg px-2",onClick:ut},D[4]||(D[4]=[k("span",null,"Reset",-1)]))])):at("",!0),l.value==="ready"?(ee(),ne("div",hc,[Fr(k("select",{"onUpdate:modelValue":D[1]||(D[1]=X=>Y.value=X),className:"border rounded-lg p-2 max-w-[100px]"},[D[5]||(D[5]=k("option",{disabled:""}," Select a Audio Input ",-1)),(ee(!0),ne(be,null,Hn(Fe(P),X=>(ee(),ne("option",{key:X.deviceId,value:X.deviceId},We(X.label),9,pc))),128))],512),[[ai,Y.value]])])):at("",!0),l.value==="loading"?(ee(),ne("div",gc,[k("p",mc,We(c.value),1),(ee(!0),ne(be,null,Hn(d.value,(X,de)=>(ee(),si(Ql,{key:de,text:X.file,percentage:X.progress||0,total:X.total||0},null,8,["text","percentage","total"]))),128))])):at("",!0)])])])):(ee(),ne("div",vc,D[7]||(D[7]=[it(" WebGPU is not supported"),k("br",null,null,-1),it("by this browser :( ")])))])],4))}});Dl(_c).mount("#app");
index.html CHANGED
@@ -13,7 +13,7 @@
13
  document.documentElement.classList.toggle('dark', true)
14
  })()
15
  </script>
16
- <script type="module" crossorigin src="/assets/index-DkY1r9ic.js"></script>
17
  <link rel="stylesheet" crossorigin href="/assets/index-BfoF9A_u.css">
18
  </head>
19
  <body class="font-sans">
 
13
  document.documentElement.classList.toggle('dark', true)
14
  })()
15
  </script>
16
+ <script type="module" crossorigin src="/assets/index-CWirHJ3J.js"></script>
17
  <link rel="stylesheet" crossorigin href="/assets/index-BfoF9A_u.css">
18
  </head>
19
  <body class="font-sans">