PhoWhisper-next / _next /static /chunks /app /page-8e71e4ff16721c33.js
huuquyet's picture
chore: bump dependencies
6ba07bb verified
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{6972:function(e,t,n){Promise.resolve().then(n.bind(n,912)),Promise.resolve().then(n.bind(n,1481)),Promise.resolve().then(n.bind(n,4543))},4543:function(e,t,n){"use strict";let a;n.r(t),n.d(t,{default:function(){return Q}});var r,i,s,o=n(7437),l=n(8472),c=n(2265),u={SAMPLING_RATE:16e3,DEFAULT_AUDIO_URL:"https://huggingface.co/spaces/huuquyet/PhoWhisper-next/resolve/main/assets/demo.wav",DEFAULT_MODEL:"huuquyet/PhoWhisper-tiny",DEFAULT_SUBTASK:"transcribe",DEFAULT_LANGUAGE:"vietnamese",DEFAULT_QUANTIZED:(a=!1,r=navigator.userAgent||navigator.vendor||("opera"in window&&"string"==typeof window.opera?window.opera:""),(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(r)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(r.substr(0,4)))&&(a=!0),a),DEFAULT_MULTILINGUAL:!1};function d(e){let t=(0,c.useRef)(null),n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{t.current&&n.current&&(n.current.src=e.audioUrl,t.current.load())},[e.audioUrl]),(0,o.jsx)("div",{className:"flex relative z-10 p-4 w-full",children:(0,o.jsx)("audio",{ref:t,controls:!0,className:"w-full h-14 rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:(0,o.jsx)("source",{ref:n,type:e.mimeType})})})}function m(e){return String(e).padStart(2,"0")}function p(e){let t=e/3600|0,n=(e-=3600*t)/60|0,a=0|(e-=60*n);return"".concat(t?"".concat(m(t),":"):"").concat(m(n),":").concat(m(a))}var y=n(7431);let h={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}};class g{updateBySource(){}setSource(e){this.source=e,this.updateBySource()}updateByData(){}setData(e){this.data=e,this.updateByData()}constructor(e="Unknown",t="Unknown"){(0,y._)(this,"name",void 0),(0,y._)(this,"type",void 0),(0,y._)(this,"source",void 0),(0,y._)(this,"data",void 0),this.name=e,this.type=t}}class f extends g{updateBySource(){this.data="";for(let e=0;e<this.source.length;e++){let t=this.source[e].toString(16);this.data+=b(t)}}updateByData(){let e=this.data.length/2;this.source=new Uint8Array(e);for(let t=0;t<e;t++){let e=this.data.substr(2*t,2);this.source[t]=Number.parseInt(e,16)}}getValue(){return Number.parseInt(this.data,16)}setValue(e){this.setData(b(e.toString(16)))}constructor(e,t){super(e,t||"Uint")}}function b(e){return e.length%2==1?"0".concat(e):e}class x extends g{getFloatArrayType(){return this.source&&4===this.source.length?Float32Array:Float64Array}updateBySource(){let e=this.source.reverse(),t=new(this.getFloatArrayType())(e.buffer);this.data=t[0]}updateByData(){let e=new Uint8Array(new(this.getFloatArrayType())([this.data]).buffer);this.source=e.reverse()}getValue(){return this.data}setValue(e){this.setData(e)}constructor(e,t){super(e,t||"Float")}}class k extends g{readByte(){return this.source[this.offset++]}readUint(){let e=this.readByte(),t=8-e.toString(2).length,n=e-(1<<7-t);for(let e=0;e<t;e++)n*=256,n+=this.readByte();return n}updateBySource(){let e;for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=e){let t=this.readUint(),n=this.readUint();e=Math.min(this.offset+n,this.source.length);let a=this.source.slice(this.offset,e),r=h[t]||{name:"Unknown",type:"Unknown"},i=g;switch(r.type){case"Container":i=k;break;case"Uint":i=f;break;case"Float":i=x}let s=new i(r.name,r.type);s.setSource(a),this.data.push({id:t,idHex:t.toString(16),data:s})}}writeUint(e){let t,n,a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(t=1,n=128;e>=n&&t<8;t++,n*=128);if(!a){let a=n+e;for(let e=t-1;e>=0;e--){let t=a%256;this.source[this.offset+e]=t,a=(a-t)/256}}this.offset+=t}writeSections(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.offset=0;for(let t=0;t<this.data.length;t++){let n=this.data[t],a=n.data.source,r=a.length;this.writeUint(n.id,e),this.writeUint(r,e),e||this.source.set(a,this.offset),this.offset+=r}return this.offset}updateByData(){let e=this.writeSections(!0);this.source=new Uint8Array(e),this.writeSections()}getSectionById(e){for(let t=0;t<this.data.length;t++){let n=this.data[t];if(n.id===e)return n.data}}constructor(e,t){super(e,t||"Container"),(0,y._)(this,"offset",0),(0,y._)(this,"data",[])}}class C extends k{fixDuration(e){let t=this.getSectionById(139690087);if(!t)return!1;let n=t.getSectionById(88713574);if(!n)return!1;let a=n.getSectionById(710577);if(!a)return!1;let r=n.getSectionById(1161);if(r){if(!(0>=r.getValue()))return!1;r.setValue(e)}else(r=new x("Duration","Float")).setValue(e),n.data.push({id:1161,data:r});return a.setValue(1e6),n.updateByData(),t.updateByData(),this.updateByData(),!0}toBlob(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"video/webm";return new Blob([this.source.buffer],{type:e})}constructor(e){super("File","File"),this.setSource(e)}}let v=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"video/webm";return new Promise((a,r)=>{try{let i=new FileReader;i.addEventListener("loadend",()=>{try{let r=i.result,s=new C(new Uint8Array(r));s.fixDuration(t)?a(s.toBlob(n)):a(e)}catch(e){r(e)}}),i.addEventListener("error",()=>r()),i.readAsArrayBuffer(e)}catch(e){r(e)}})};function w(e){let[t,n]=(0,c.useState)(!1),[a,r]=(0,c.useState)(0),[i,s]=(0,c.useState)(null),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useRef)([]),m=(0,c.useRef)(null),y=async()=>{s(null);let t=Date.now();try{l.current||(l.current=await navigator.mediaDevices.getUserMedia({audio:!0}));let a=function(){let e=["audio/webm","audio/mp4","audio/ogg","audio/wav","audio/aac"];for(let t=0;t<e.length;t++)if(MediaRecorder.isTypeSupported(e[t]))return e[t]}(),r=new MediaRecorder(l.current,{mimeType:a});u.current=r,r.addEventListener("dataavailable",async n=>{if(n.data.size>0&&d.current.push(n.data),"inactive"===r.state){let n=Date.now()-t,r=new Blob(d.current,{type:a});"audio/webm"===a&&(r=await v(r,n,r.type)),s(r),e.onRecordingComplete(r),d.current=[]}}),r.start(),n(!0)}catch(e){console.error("Error accessing microphone:",e)}},h=()=>{u.current&&"recording"===u.current.state&&(u.current.stop(),r(0),n(!1))};return(0,c.useEffect)(()=>{if(t){let e=setInterval(()=>{r(e=>e+1)},1e3);return()=>{clearInterval(e)}}return()=>{}},[t]),(0,o.jsxs)("div",{className:"flex flex-col justify-center items-center",children:[(0,o.jsx)("button",{type:"button",className:"m-2 inline-flex justify-center rounded-md border border-transparent px-4 py-2 text-sm font-medium text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 transition-all duration-200 ".concat(t?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"),onClick:()=>{t?h():y()},children:t?"Stop Recording (".concat(p(a),")"):"Start Recording"}),i&&(0,o.jsx)("audio",{className:"w-full",ref:m,controls:!0,children:(0,o.jsx)("source",{src:URL.createObjectURL(i),type:i.type})})]})}function U(e){let{text:t,percentage:n}=e;return n=null!=n?n:0,(0,o.jsx)("div",{className:"mt-0.5 w-full relative text-sm text-white background-bg-cyan-400 bg-gray-200 border-1 border-gray-400 rounded-lg text-left overflow-hidden",children:(0,o.jsxs)("div",{className:"top-0 h-full bg-blue-500 whitespace-nowrap px-2",style:{width:"".concat(n,"%")},children:[t," (","".concat(n.toFixed(2),"%"),")"]})})}function j(e){let{isModelLoading:t,isTranscribing:n,onClick:a,...r}=e;return(0,o.jsx)("button",{...r,onClick:e=>{!a||n||t||a(e)},disabled:n,className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 inline-flex items-center",children:t?(0,o.jsx)(S,{text:"Loading model..."}):n?(0,o.jsx)(S,{text:"Transcribing..."}):"Transcribe Audio"})}function S(e){return(0,o.jsxs)("div",{role:"status",children:[(0,o.jsxs)("svg",{"aria-hidden":"true",role:"status",className:"inline w-4 h-4 mr-3 text-white animate-spin",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"#E5E7EB"}),(0,o.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentColor"})]}),e.text]})}var T=n(4923),D=n(9717);function B(e){let{show:t,onClose:n,onSubmit:a,title:r,content:i,submitText:s,submitEnabled:l=!0}=e;return(0,o.jsx)(T.u,{appear:!0,show:t,as:c.Fragment,children:(0,o.jsxs)(D.Vq,{as:"div",className:"relative z-10",onClose:n,children:[(0,o.jsx)(T.u.Child,{as:c.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,o.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-25"})}),(0,o.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,o.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,o.jsx)(T.u.Child,{as:c.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,o.jsxs)(D.Vq.Panel,{className:"w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all",children:[(0,o.jsx)(D.Vq.Title,{as:"h3",className:"text-lg font-medium leading-6 text-gray-900",children:r}),(0,o.jsx)("div",{className:"mt-3 text-sm text-gray-500",children:i}),(0,o.jsxs)("div",{className:"mt-4 flex flex-row-reverse",children:[s&&(0,o.jsx)("button",{type:"button",disabled:!l,className:"inline-flex ml-4 justify-center rounded-md border border-transparent ".concat(l?"bg-indigo-600":"bg-grey-300"," px-4 py-2 text-sm font-medium text-indigo-100 ").concat(l?"hover:bg-indigo-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2":""," transition-all duration-300"),onClick:a,children:s}),(0,o.jsx)("button",{type:"button",className:"inline-flex justify-center rounded-md border border-transparent bg-indigo-100 px-4 py-2 text-sm font-medium text-indigo-900 hover:bg-indigo-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 transition-all duration-300",onClick:n,children:"Close"})]})]})})})})]})})}function F(e){return(0,o.jsx)("div",{children:(0,o.jsx)("input",{...e,type:"url",className:"my-2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",placeholder:"www.example.com",required:!0})})}function L(e){return((e=e.toLowerCase()).match(/\w+.?/g)||[]).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}let 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 E(e){let[t,n]=(0,c.useState)(void 0),[a,r]=(0,c.useState)(void 0),[i,s]=(0,c.useState)(void 0),m=void 0!==t,p=()=>{r(void 0),s(void 0)},y=async(e,t)=>{let n=new AudioContext({sampleRate:u.SAMPLING_RATE}),a=URL.createObjectURL(new Blob([e],{type:"audio/*"}));r({buffer:await n.decodeAudioData(e),url:a,source:"URL",mimeType:t})},h=async e=>{p(),n(0);let t=URL.createObjectURL(e),a=new FileReader;a.onprogress=e=>{n(e.loaded/e.total||0)},a.onloadend=async()=>{let i=new AudioContext({sampleRate:u.SAMPLING_RATE}),s=a.result,o=await i.decodeAudioData(s);n(void 0),r({buffer:o,url:t,source:"RECORDING",mimeType:e.type})},a.readAsArrayBuffer(e)},g=async e=>{if(i)try{r(void 0),n(0);let{data:t,headers:a}=await l.Z.get(i,{signal:e.signal,responseType:"arraybuffer",onDownloadProgress(e){n(e.progress||0)}}),s=a["content-type"];s&&"audio/wave"!==s||(s="audio/wav"),y(t,s)}catch(e){console.log("Request failed or aborted",e)}finally{n(void 0)}};return(0,c.useEffect)(()=>{if(i){let e=new AbortController;return g(e),()=>{e.abort()}}},[i]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex flex-col justify-center items-center rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:[(0,o.jsxs)("div",{className:"flex flex-row space-x-2 py-2 w-full px-2",children:[(0,o.jsx)(z,{icon:(0,o.jsx)(G,{}),text:"From URL",onUrlUpdate:t=>{e.transcriber.onInputChange(),s(t)}}),(0,o.jsx)(I,{}),(0,o.jsx)(q,{icon:(0,o.jsx)(H,{}),text:"From file",onFileUpdate:(t,n,a)=>{e.transcriber.onInputChange(),r({buffer:t,url:n,source:"FILE",mimeType:a})}}),navigator.mediaDevices&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(I,{}),(0,o.jsx)(O,{icon:(0,o.jsx)(K,{}),text:"Record",setAudioData:t=>{e.transcriber.onInputChange(),h(t)}})]})]}),(0,o.jsx)(M,{progress:m?t:+!!a})]}),a&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d,{audioUrl:a.url,mimeType:a.mimeType}),(0,o.jsxs)("div",{className:"relative w-full flex justify-center items-center",children:[(0,o.jsx)(j,{onClick:()=>{e.transcriber.start(a.buffer)},isModelLoading:e.transcriber.isModelLoading,isTranscribing:e.transcriber.isBusy}),(0,o.jsx)(A,{className:"absolute right-4",transcriber:e.transcriber,icon:(0,o.jsx)(Z,{})})]}),e.transcriber.progressItems.length>0&&(0,o.jsxs)("div",{className:"relative z-10 p-4 w-full",children:[(0,o.jsx)("label",{children:"Loading model files... (only run once)"}),e.transcriber.progressItems.map(e=>(0,o.jsx)("div",{children:(0,o.jsx)(U,{text:e.file,percentage:e.progress})},e.file))]})]})]})}function A(e){let[t,n]=(0,c.useState)(!1),a=()=>{n(!1)};return(0,o.jsxs)("div",{className:e.className,children:[(0,o.jsx)(W,{icon:e.icon,onClick:()=>{n(!0)}}),(0,o.jsx)(R,{show:t,onSubmit:e=>{a()},onClose:a,transcriber:e.transcriber})]})}function R(e){let t=Object.values(N).map(L),n={"huuquyet/PhoWhisper-tiny":[43,154],"huuquyet/PhoWhisper-base":[75,285],"huuquyet/PhoWhisper-small":[250,970],"huuquyet/PhoWhisper-medium":[776],"huuquyet/PhoWhisper-large":[3139],"Xenova/whisper-tiny":[41,152],"Xenova/whisper-base":[77,291]};return(0,o.jsx)(B,{show:e.show,title:"Settings",content:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("label",{children:"Select the model to use."}),(0,o.jsx)("select",{className:"mt-1 mb-1 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.model,onChange:t=>{e.transcriber.setModel(t.target.value)},children:Object.keys(n).filter(t=>e.transcriber.quantized||2===n[t].length).filter(t=>!e.transcriber.multilingual||!t.startsWith("distil-whisper/")).map(t=>(0,o.jsx)("option",{value:t,children:"".concat(t).concat(e.transcriber.multilingual||t.startsWith("distil-whisper/")||t.startsWith("huuquyet")?"":".en"," (").concat(n[t][e.transcriber.quantized?0:1],"MB)")},t))}),(0,o.jsxs)("div",{className:"flex justify-between items-center mb-3 px-1",children:[(0,o.jsxs)("div",{className:"flex",children:[(0,o.jsx)("input",{id:"multilingual",type:"checkbox",checked:e.transcriber.multilingual,onChange:t=>{e.transcriber.setMultilingual(t.target.checked)}}),(0,o.jsx)("label",{htmlFor:"multilingual",className:"ms-1",children:"Multilingual"})]}),(0,o.jsxs)("div",{className:"flex",children:[(0,o.jsx)("input",{id:"quantize",type:"checkbox",checked:e.transcriber.quantized,onChange:t=>{e.transcriber.setQuantized(t.target.checked)}}),(0,o.jsx)("label",{htmlFor:"quantize",className:"ms-1",children:"Quantized"})]})]}),e.transcriber.multilingual&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("label",{children:"Select the source language."}),(0,o.jsx)("select",{className:"mt-1 mb-3 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.language,onChange:t=>{e.transcriber.setLanguage(t.target.value)},children:Object.keys(N).map((e,n)=>(0,o.jsx)("option",{value:e,children:t[n]},e))}),(0,o.jsx)("label",{children:"Select the task to perform."}),(0,o.jsxs)("select",{className:"mt-1 mb-3 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",defaultValue:e.transcriber.subtask,onChange:t=>{e.transcriber.setSubtask(t.target.value)},children:[(0,o.jsx)("option",{value:"transcribe",children:"Transcribe"}),(0,o.jsx)("option",{value:"translate",children:"Translate (to Vietnamese)"})]})]})]}),onClose:e.onClose,onSubmit:()=>{}})}function I(){return(0,o.jsx)("div",{className:"w-[1px] bg-slate-200"})}function M(e){return(0,o.jsx)(P,{progress:"".concat(Math.round(100*e.progress),"%")})}function P(e){return(0,o.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700",children:(0,o.jsx)("div",{className:"bg-blue-600 h-1 rounded-full transition-all duration-100",style:{width:e.progress}})})}function z(e){let[t,n]=(0,c.useState)(!1),a=()=>{n(!1)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(W,{icon:e.icon,text:e.text,onClick:()=>{n(!0)}}),(0,o.jsx)(_,{show:t,onSubmit:t=>{e.onUrlUpdate(t),a()},onClose:a})]})}function _(e){let[t,n]=(0,c.useState)(u.DEFAULT_AUDIO_URL);return(0,o.jsx)(B,{show:e.show,title:"From URL",content:(0,o.jsxs)(o.Fragment,{children:["Enter the URL of the audio file you want to load.",(0,o.jsx)(F,{onChange:e=>{n(e.target.value)},value:t})]}),onClose:e.onClose,submitText:"Load",onSubmit:()=>{e.onSubmit(t)}})}function q(e){let t=document.createElement("input");return t.type="file",t.oninput=n=>{let a=n.target.files;if(!a)return;let r=URL.createObjectURL(a[0]),i=a[0].type,s=new FileReader;s.addEventListener("load",async t=>{var n;let a=null===(n=t.target)||void 0===n?void 0:n.result;if(!a)return;let s=new AudioContext({sampleRate:u.SAMPLING_RATE}),o=await s.decodeAudioData(a);e.onFileUpdate(o,r,i)}),s.readAsArrayBuffer(a[0]),t.value=""},(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(W,{icon:e.icon,text:e.text,onClick:()=>t.click()})})}function O(e){let[t,n]=(0,c.useState)(!1),a=()=>{n(!1)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(W,{icon:e.icon,text:e.text,onClick:()=>{n(!0)}}),(0,o.jsx)(V,{show:t,onSubmit:t=>{t&&(e.setAudioData(t),a())},onClose:a})]})}function V(e){let[t,n]=(0,c.useState)();return(0,o.jsx)(B,{show:e.show,title:"From Recording",content:(0,o.jsxs)(o.Fragment,{children:["Record audio using your microphone",(0,o.jsx)(w,{onRecordingComplete:e=>{n(e)}})]}),onClose:()=>{e.onClose(),n(void 0)},submitText:"Load",submitEnabled:void 0!==t,onSubmit:()=>{e.onSubmit(t),n(void 0)}})}function W(e){return(0,o.jsxs)("button",{type:"button",onClick:e.onClick,className:"flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200",children:[(0,o.jsx)("div",{className:"w-7 h-7",children:e.icon}),e.text&&(0,o.jsx)("div",{className:"ml-2 break-text text-center text-md w-30",children:e.text})]})}function G(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"})})}function H(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})})}function Z(){return(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.25",stroke:"currentColor",children:[(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z"}),(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function K(){return(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,o.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"})})}function J(e){var t;let{transcribedData:n}=e,a=(0,c.useRef)(null),r=(e,t)=>{let n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,a.click(),URL.revokeObjectURL(n)};return(0,c.useEffect)(()=>{a.current&&64>=Math.abs(a.current.offsetHeight+a.current.scrollTop-a.current.scrollHeight)&&(a.current.scrollTop=a.current.scrollHeight)}),(0,o.jsxs)("div",{ref:a,className:"w-full flex flex-col my-2 p-4 max-h-[20rem] overflow-y-auto",children:[null==n?void 0:null===(t=n.chunks)||void 0===t?void 0:t.map((e,t)=>(0,o.jsxs)("div",{className:"w-full flex flex-row mb-2 bg-white rounded-lg p-4 shadow-xl shadow-black/5 ring-1 ring-slate-700/10",children:[(0,o.jsx)("div",{className:"mr-5",children:p(e.timestamp[0])}),e.text]},"".concat(t,"-").concat(e.text))),n&&!n.isBusy&&(0,o.jsxs)("div",{className:"w-full text-right",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{var e;r(new Blob([(null!==(e=null==n?void 0:n.chunks)&&void 0!==e?e:[]).map(e=>e.text).join("").trim()],{type:"text/plain"}),"transcript.txt")},className:"text-white bg-green-500 hover:bg-green-600 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-4 py-2 text-center mr-2 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 inline-flex items-center",children:"Export TXT"}),(0,o.jsx)("button",{type:"button",onClick:()=>{var e;let t=JSON.stringify(null!==(e=null==n?void 0:n.chunks)&&void 0!==e?e:[],null,2);r(new Blob([t=t.replace(/( {4}"timestamp": )\[\s+(\S+)\s+(\S+)\s+\]/gm,"$1[$2 $3]")],{type:"application/json"}),"transcript.json")},className:"text-white bg-green-500 hover:bg-green-600 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-4 py-2 text-center mr-2 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 inline-flex items-center",children:"Export JSON"})]})]})}function Q(){let e=function(){let[e,t]=(0,c.useState)(void 0),[a,r]=(0,c.useState)(!1),[i,s]=(0,c.useState)(!1),[o,l]=(0,c.useState)([]),d=function(e){let[t]=(0,c.useState)(()=>(function(e){let t=new Worker(n.tu(new URL(n.p+n.u(251),n.b)),{type:void 0});return t.addEventListener("message",e),t})(e));return t}(e=>{let n=e.data;switch(n.status){case"progress":l(e=>e.map(e=>e.file===n.file?{...e,progress:n.progress}:e));break;case"update":t({isBusy:!0,text:n.data[0],chunks:n.data[1].chunks});break;case"complete":t({isBusy:!1,text:n.data.text,chunks:n.data.chunks}),r(!1);break;case"initiate":s(!0),l(e=>[...e,n]);break;case"ready":s(!1);break;case"error":r(!1),alert("".concat(n.data.message," This is most likely because you are using Safari on an M1/M2 Mac. Please try again from Chrome, Firefox, or Edge.\n\nIf this is not the case, please file a bug report."));break;case"done":l(e=>e.filter(e=>e.file!==n.file))}}),[m,p]=(0,c.useState)(u.DEFAULT_MODEL),[y,h]=(0,c.useState)(u.DEFAULT_SUBTASK),[g,f]=(0,c.useState)(u.DEFAULT_QUANTIZED),[b,x]=(0,c.useState)(u.DEFAULT_MULTILINGUAL),[k,C]=(0,c.useState)(u.DEFAULT_LANGUAGE),v=(0,c.useCallback)(()=>{t(void 0)},[]),w=(0,c.useCallback)(async e=>{if(e){let n;if(t(void 0),r(!0),2===e.numberOfChannels){let t=Math.sqrt(2),a=e.getChannelData(0),r=e.getChannelData(1);n=new Float32Array(a.length);for(let i=0;i<e.length;++i)n[i]=t*(a[i]+r[i])/2}else n=e.getChannelData(0);d.postMessage({audio:n,model:m,multilingual:b,quantized:g,subtask:b?y:null,language:b&&"auto"!==k?k:null})}},[d,m,b,g,y,k]);return(0,c.useMemo)(()=>({onInputChange:v,isBusy:a,isModelLoading:i,progressItems:o,start:w,output:e,model:m,setModel:p,multilingual:b,setMultilingual:x,quantized:g,setQuantized:f,subtask:y,setSubtask:h,language:k,setLanguage:C}),[a,i,o,w,e,m,b,g,y,k])}();return(0,o.jsxs)("div",{className:"flex justify-center items-center min-h-screen",children:[(0,o.jsxs)("div",{className:"container flex flex-col justify-center items-center",children:[(0,o.jsx)("h1",{className:"text-5xl font-extrabold tracking-tight text-slate-900 sm:text-7xl text-center",children:"PhoWhisper Web"}),(0,o.jsx)("h2",{className:"mt-3 mb-5 px-4 text-center text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl",children:"ML-powered speech recognition for Vietnamese directly in your browser"}),(0,o.jsx)(E,{transcriber:e}),(0,o.jsx)(J,{transcribedData:e.output})]}),(0,o.jsxs)("div",{className:"absolute bottom-4",children:["Made with"," ",(0,o.jsx)("a",{className:"underline",href:"https://github.com/xenova/transformers.js",children:"\uD83E\uDD17 Transformers.js"})," ","+ Next.js"," ",(0,o.jsx)("a",{className:"underline",href:"https://github.com/huuquyet/PhoWhisper-next",children:"Give it a ⭐️"})]})]})}(i=s||(s={})).URL="URL",i.FILE="FILE",i.RECORDING="RECORDING"}},function(e){e.O(0,[72,727,971,190,744],function(){return e(e.s=6972)}),_N_E=e.O()}]);