(function(){"use strict";var t={1019:function(t,e,s){var a=s(144),o=s(1096),i=s(3551),l=function(){var t=this,e=t._self._c;return e(o.Z,[e(i.Z,[e("DemoHeader"),e("EspnetOnnxDemo"),e("DemoFooter")],1)],1)},r=[],n=s(3058),d=s(4437),c=s(6035),h=s(5294),u=s(5234),m=function(){var t=this,e=t._self._c;return e(c.Z,[e(n.Z,{staticClass:"mt-4",attrs:{flat:""}},[e(h.Z,[e(d.Z,{attrs:{cols:"3"}},[e("a",{attrs:{href:"https://github.com/espnet/espnet"}},[e("img",{attrs:{src:"https://masao-someki.github.io/espnet_onnx_demo/image/espnet-logo.png",width:"100%"}})])]),e(u.Z),e(d.Z,{staticStyle:{"text-align":"right"},attrs:{cols:"1"}},[e("a",{attrs:{href:"https://github.com/espnet/espnet_onnx"}},[e("img",{attrs:{src:"https://masao-someki.github.io/espnet_onnx_demo/image/github-mark.png",width:"100%"}})])])],1)],1)],1)},p=[],g={name:"DemoHeader",data:()=>({hoverFlag:!1}),methods:{hover(){this.hoverFlag=!0},out(){this.hoverFlag=!1}}},v=g,f=s(1001),y=(0,f.Z)(v,m,p,!1,null,null,null),_=y.exports,b=s(2537),Z=function(){var t=this,e=t._self._c;return e(c.Z,[e(b.Z,{attrs:{padless:"",absolute:""}},[e(h.Z,{attrs:{justify:"center","no-gutters":""}},[e(d.Z,{staticClass:"py-4 text-center",attrs:{color:"#BFBFBF",cols:"12"}},[t._v(" "+t._s((new Date).getFullYear())+" — "),e("strong",[t._v("ESPnet-ONNX")])])],1)],1)],1)},S=[],x={name:"DemoFooter"},w=x,C=(0,f.Z)(w,Z,S,!1,null,null,null),T=C.exports,A=s(5223),F=s(9868),k=function(){var t=this,e=t._self._c;return e(c.Z,[e(n.Z,{attrs:{flat:""}},[e(A.EB,[e("span",{staticClass:"text-h3"},[t._v("ESPnet-ONNX demo")])]),e(A.ZB,{staticClass:"body-1"},[t._v(" This is a demonstration space of ESPnet-ONNX project. Please select ASR or TTS to play! ")])],1),e("MenuBar",{staticClass:"mt-6 mx-auto",attrs:{options:t.options},on:{select:t.menuChanged},model:{value:t.selected,callback:function(e){t.selected=e},expression:"selected"}}),e(F.Z,{staticClass:"mb-10"},[e("div",{directives:[{name:"show",rawName:"v-show",value:"ASR"==t.menuSelected,expression:"menuSelected == 'ASR'"}]},[e("ASRDemoSheet",{staticClass:"mt-3"})],1),e("div",{directives:[{name:"show",rawName:"v-show",value:"TTS"==t.menuSelected,expression:"menuSelected == 'TTS'"}]},[e("TTSDemoSheet",{staticClass:"mt-3"})],1)])],1)},E=[],L=s(5057),O=function(){var t=this,e=t._self._c;return e("div",{staticClass:"btn-containrt_foreground",style:t.cssVariables},[e("div",{staticClass:"btn-containrt"},t._l(t.localOptions,(function(s,a){return e("div",{key:`menu-label-${a}`,class:{[`btn-item-${a} labels`]:!0,["checked"]:s.isActive,["unchecked"]:!s.isActive},on:{click:function(e){return t.handleLabelClick(s)}}},[e("div",{staticClass:"active-label"},[s.badge?e("div",{staticClass:"btn-badge"},[t._v(" "+t._s(s.badge)+" ")]):t._e(),t.hasSlot("icon")?t._t("icon",null,{props:s}):[e(L.Z,[t._v(" "+t._s(s.icon)+" ")])]],2),e("div",{staticClass:"btn-title"},[t.hasSlot("title")?t._t("title",null,{props:s}):[t._v(" "+t._s(s.title)+" ")]],2)])})),0)])},P=[],R={model:{prop:"value",event:"update"},props:{value:{default:null},options:{type:Array,default:()=>[]},badgeColor:{type:String,default:"#FBC02D"}},data:()=>({localOptions:[],showable:!1}),created(){this.localOptions=this.options.map((t=>({...t,isActive:this.isActive(t)})))},computed:{cssVariables(){return{"--color-badge":this.badgeColor}},hasActiveClass(){return this.localOptions.some((t=>t.isActive))}},methods:{handleLabelClick(t){this.showable||this.toggleClass(),this.updateValue(t.id),this.$emit("select",t.title)},updateValue(t){this.localOptions.forEach((e=>e.isActive=this.isActive(e,t))),this.$emit("update",t)},toggleClass(){this.showable=!this.showable},isActive(t,e=this.value){return t.id==e||(t.childs||[]).find((t=>t.id==e))},hasSlot(t){return this.$slots[t]||this.$scopedSlots[t]}}},D=R,M=(0,f.Z)(D,O,P,!1,null,"002ef1c4",null),I=M.exports,j=s(4635),N=s(1828),B=s(5731),V=s(4397),$=s(5617),X=function(){var t=this,e=t._self._c;return e(c.Z,[e(F.Z,{staticClass:"mt-6 mx-3"},[e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Select model ")])]),e(d.Z,{attrs:{cols:"7"}},[e(B.Z,{attrs:{items:t.models,error:t.selectError,dense:""},model:{value:t.model,callback:function(e){t.model=e},expression:"model"}})],1),e(d.Z,{attrs:{cols:"2"}},[e(N.Z,{attrs:{outlined:"",width:"100%",loading:t.loadingFlag},on:{click:t.loadModel}},[t._v(" Load ")])],1)],1),e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("div",{staticClass:"my-auto"},[e("span",{staticClass:"text-h6"},[t._v(" Upload audio ")])])]),e(d.Z,{attrs:{cols:"7"}},[e("audio-recorder",{staticStyle:{"box-shadow":"none",background:"none"},attrs:{attempts:3,time:1,"sample-rate":"16000","show-download-button":!1,"show-upload-button":!1,format:"mp3","select-record":t.selectRecord,"after-recording":t.afterRecord}})],1),e(d.Z,{staticClass:"d-flex flex-column",attrs:{cols:"2"}},[e(u.Z),e(N.Z,{staticClass:"mt-auto",attrs:{outlined:"",width:"100%",loading:t.ASRLoadingFlag},on:{click:t.runModel}},[t._v(" Run ")])],1)],1),e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Text ")])]),e(d.Z,{attrs:{cols:"9"}},[e($.Z,{attrs:{dense:"",readonly:""},model:{value:t.text,callback:function(e){t.text=e},expression:"text"}})],1)],1),e(h.Z,{staticClass:"mt-6"},[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Model Detail ")])]),e(d.Z,{attrs:{cols:"9"}},[e(n.Z,{attrs:{flat:""}},[e(V.Z,[e("tbody",t._l(t.modelInfo[t.model],(function(s){return e("tr",{key:s.name},[e("td",[t._v(t._s(s.name))]),e("td",[t._v(t._s(s.value))])])})),0)])],1)],1)],1)],1),e(j.Z,{attrs:{value:t.showAlert,type:t.barType,"colored-border":"",border:"top",elevation:"2"}},[t._v(" "+t._s(t.message))])],1)},H=[],G=s(6154),z={name:"ASRDemoSheet",data:()=>({model:"",models:["pyf98/librispeech_conformer_hop_length160"],modelInfo:{"pyf98/librispeech_conformer_hop_length160":[{name:"url",value:"https://huggingface.co/pyf98/librispeech_conformer_hop_length160"},{name:"encoder",value:"Conformer"},{name:"decoder",value:"Transformer"}]},loadingFlag:!1,text:"",ASRLoadingFlag:!1,showAlert:!1,message:"",barType:"success",selectError:!1,audioFile:"",audioError:!1,soundSrc:[],record:null}),methods:{hide_alert:function(){window.setInterval((()=>{this.showAlert=!1}),3e3)},loadModel(){if(this.loadingFlag=!0,""===this.model)return this.showAlert=!0,this.selectError=!0,this.message="Please select a model",this.loadingFlag=!1,this.barType="error",void this.hide_alert();this.selectError=!1,G.Z.get("/api/asr/load_model",{params:{model_name:this.model}}).then((()=>{this.message="Successfully loaded model",this.barType="success",this.loadingFlag=!1,this.alert=!0,this.modelLoaded=!0,this.showAlert=!0,this.hide_alert()})).catch((t=>{this.message="Error happened while loading model",this.loadingFlag=!1,this.alert=!0,this.barType="error",this.showAlert=!0,this.hide_alert(),console.log(t)}))},runModel(){if(this.ASRLoadingFlag=!0,!this.record)return this.showAlert=!0,this.audioError=!0,this.message="Please record at least one audio.",this.ASRLoadingFlag=!1,this.barType="error",void this.hide_alert();let t=new FormData;t.append("audio",this.record.blob,`${this.record.filename}.mp3`),G.Z.post("/api/asr/recognize",t,{headers:{"Content-Type":"multipart/form-data"}}).then((t=>{this.message="Recognition finished.",this.barType="success",this.ASRLoadingFlag=!1,this.alert=!0,this.text=t.data.text,this.hide_alert()})).catch((t=>{this.message="Error happened while executing model",this.ASRLoadingFlag=!1,this.alert=!0,this.barType="error",this.hide_alert(),console.log(t)}))},selectRecord(t){this.record=t},afterRecord(t){this.record=t}}},U=z,W=(0,f.Z)(U,X,H,!1,null,null,null),Y=W.exports,q=function(){var t=this,e=t._self._c;return e(c.Z,[e(F.Z,{staticClass:"mt-6 mx-3"},[e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Select model ")])]),e(d.Z,{attrs:{cols:"7"}},[e(B.Z,{attrs:{items:t.models,dense:"",error:t.selectError},model:{value:t.model,callback:function(e){t.model=e},expression:"model"}})],1),e(d.Z,{attrs:{cols:"2"}},[e(N.Z,{attrs:{outlined:"",width:"100%",loading:t.loadingFlag},on:{click:t.loadModel}},[t._v(" Load ")])],1)],1),e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Write text ")])]),e(d.Z,{attrs:{cols:"7"}},[e($.Z,{attrs:{dense:"",clearable:"",rows:"2",counter:"",error:t.textError,rules:t.textLengthRules},model:{value:t.text,callback:function(e){t.text=e},expression:"text"}})],1),e(d.Z,{attrs:{cols:"2"}},[e(N.Z,{attrs:{outlined:"",width:"100%",loading:t.TTSLoadingFlag},on:{click:t.runModel}},[t._v(" Generate ")])],1)],1),e(h.Z,[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Generated audio ")])]),e(d.Z,{attrs:{cols:"9"}},[e("AudioPlayer",{ref:"audioPlayer"})],1)],1),e(h.Z,{staticClass:"mt-6"},[e(d.Z,{staticClass:"py-auto",staticStyle:{"text-align":"center"},attrs:{cols:"3",height:"100%"}},[e("span",{staticClass:"text-h6"},[t._v(" Model Detail ")])]),e(d.Z,{attrs:{cols:"9"}},[e(n.Z,{attrs:{flat:""}},[e(V.Z,[e("tbody",t._l(t.modelInfo[t.model],(function(s){return e("tr",{key:s.name},[e("td",[t._v(t._s(s.name))]),e("td",[t._v(t._s(s.value))])])})),0)])],1)],1)],1)],1),e(j.Z,{attrs:{value:t.showAlert,type:t.barType,"colored-border":"",border:"top",elevation:"2"}},[t._v(" "+t._s(t.message))])],1)},J=[],K=s(2059),Q=function(){var t=this,e=t._self._c;return e("div",{staticClass:"player"},[e(h.Z,{staticClass:"player-controls ma-0"},[e(d.Z,{staticClass:"pa-2",staticStyle:{"text-align":"center"},attrs:{cols:"1",title:"Stop"}},[e(N.Z,{attrs:{icon:""},on:{click:t.stop}},[e(L.Z,[t._v("mdi-stop")])],1)],1),e(d.Z,{staticClass:"pa-2",staticStyle:{"text-align":"center"},attrs:{cols:"1",title:"Play/Pause"}},[e(N.Z,{attrs:{icon:""},on:{click:function(e){t.playing=!t.playing}}},[e(L.Z,{directives:[{name:"show",rawName:"v-show",value:!t.playing,expression:"!playing"}]},[t._v("mdi-play")]),e(L.Z,{directives:[{name:"show",rawName:"v-show",value:t.playing,expression:"playing"}]},[t._v("mdi-pause")])],1)],1),e(d.Z,{staticClass:"pa-0",attrs:{cols:"6"}},[e("div",{staticClass:"player-progress",attrs:{title:"Time played : Total time"},on:{click:t.seek}},[e("div",{staticClass:"player-seeker",style:{width:this.percentComplete+"%"}})]),e("div",{staticClass:"player-time"},[e("div",{staticClass:"player-time-current"},[t._v(t._s(t.currentTime))]),e("div",{staticClass:"player-time-total"},[t._v(t._s(t.durationTime))])])]),e(d.Z,{staticClass:"pa-2",staticStyle:{"text-align":"center"},attrs:{cols:"4"}},[e(K.Z,{attrs:{"prepend-icon":"mdi-volume-high",max:"100",width:"100%",dense:"","hide-details":"auto"},model:{value:t.volume,callback:function(e){t.volume=e},expression:"volume"}})],1)],1)],1)},tt=[];const et=t=>{let e=new Date(1e3*t).toISOString().substr(11,8);return 0===e.indexOf("00:")?e.substr(3):e};var st={name:"ASRDemoSheet",props:{file:{type:String,default:null},autoPlay:{type:Boolean,default:!1},loop:{type:Boolean,default:!1}},data:()=>({audio:void 0,currentSeconds:0,durationSeconds:0,innerLoop:!1,loaded:!1,playing:!1,previousVolume:35,showVolume:!1,volume:100}),computed:{currentTime(){return et(this.currentSeconds)},durationTime(){return et(this.durationSeconds)},percentComplete(){return parseInt(this.currentSeconds/this.durationSeconds*100)},muted(){return this.volume/100===0}},watch:{playing(t){if(t)return this.audio.play();this.audio.pause()},volume(){this.showVolume=!1,this.audio.volume=this.volume/100}},methods:{download(){this.stop(),window.open(this.file,"download")},load(){if(this.audio.readyState>=2)return this.loaded=!0,this.durationSeconds=parseInt(this.audio.duration),this.playing=this.autoPlay;throw new Error("Failed to load sound file.")},mute(){if(this.muted)return this.volume=this.previousVolume;this.previousVolume=this.volume,this.volume=0},seek(t){if(!this.playing||"SPAN"===t.target.tagName)return;const e=t.target.getBoundingClientRect(),s=(t.clientX-e.left)/e.width;this.audio.currentTime=parseInt(this.audio.duration*s)},stop(){this.playing=!1,this.audio.currentTime=0},update(){this.currentSeconds=parseInt(this.audio.currentTime)},reload(){this.audio=new Audio("/static/sample.wav"),this.audio.addEventListener("timeupdate",this.update),this.audio.addEventListener("loadeddata",this.load),this.audio.addEventListener("pause",(()=>{this.playing=!1})),this.audio.addEventListener("play",(()=>{this.playing=!0})),this.playing=!1,this.durationSeconds=parseInt(this.audio.duration)}},created(){this.innerLoop=this.loop}},at=st,ot=(0,f.Z)(at,Q,tt,!1,null,null,null),it=ot.exports,lt={name:"ASRDemoSheet",components:{AudioPlayer:it},data:()=>({model:"",models:["kan-bayashi/ljspeech_vits"],modelInfo:{"kan-bayashi/ljspeech_vits":[{name:"url",value:"https://huggingface.co/espnet/kan-bayashi_ljspeech_vits"},{name:"model",value:"VITS"},{name:"sample_rate",value:22050}]},counter:{max:20},loadingFlag:!1,text:"",TTSLoadingFlag:!1,textLengthRules:[t=>t.length<=100||"Maximum 100 characters allowed"],showAlert:!1,message:"",modelLoaded:!1,textError:!1,barType:"success",selectError:!1}),methods:{hide_alert:function(){window.setInterval((()=>{this.showAlert=!1}),3e3)},loadModel:function(){if(this.loadingFlag=!0,""===this.model)return this.showAlert=!0,this.selectError=!0,this.message="Please select a model",this.loadingFlag=!1,this.barType="error",void this.hide_alert();this.selectError=!1,G.Z.get("/api/tts/load_model",{params:{model_name:this.model,fs:this.modelInfo[this.model][2].value}}).then((()=>{this.message="Successfully loaded model",this.barType="success",this.loadingFlag=!1,this.alert=!0,this.modelLoaded=!0,this.showAlert=!0,this.hide_alert()})).catch((t=>{this.message="Error happened while loading model",this.loadingFlag=!1,this.alert=!0,this.barType="error",this.showAlert=!0,this.hide_alert(),console.log(t)}))},runModel:function(){return this.TTSLoadingFlag=!0,this.modelLoaded?this.text?(this.selectError=!1,void G.Z.post("/api/tts/generate",{text:this.text}).then((()=>{this.message="Successfully generated audio",this.barType="success",this.TTSLoadingFlag=!1,this.alert=!0,this.hide_alert(),this.$refs.audioPlayer.reload()})).catch((t=>{this.message="Error happened while loading model",this.TTSLoadingFlag=!1,this.alert=!0,this.barType="error",this.hide_alert(),console.log(t)}))):(this.showAlert=!0,this.textError=!0,this.message="Please write text.",this.TTSLoadingFlag=!1,this.barType="error",void this.hide_alert()):(this.showAlert=!0,this.selectError=!0,this.message="Please load a model before generating audio.",this.TTSLoadingFlag=!1,this.barType="error",void this.hide_alert())}}},rt=lt,nt=(0,f.Z)(rt,q,J,!1,null,null,null),dt=nt.exports,ct={name:"EspnetOnnxDemo",components:{MenuBar:I,ASRDemoSheet:Y,TTSDemoSheet:dt},data:()=>({selected:1,options:[{id:1,icon:"mdi-microphone-message",title:"ASR"},{id:2,icon:"mdi-speaker-message",title:"TTS"}],menuSelected:"ASR"}),methods:{menuChanged:function(t){this.menuSelected!=t&&(this.menuSelected=t)}}},ht=ct,ut=(0,f.Z)(ht,k,E,!1,null,null,null),mt=ut.exports,pt={name:"App",components:{DemoHeader:_,DemoFooter:T,EspnetOnnxDemo:mt}},gt=pt,vt=(0,f.Z)(gt,l,r,!1,null,null,null),ft=vt.exports,yt=s(2250);a.ZP.use(yt.Z);var _t=new yt.Z({}),bt=s(579),Zt=s.n(bt);a.ZP.use(Zt()),a.ZP.config.productionTip=!1,new a.ZP({vuetify:_t,render:t=>t(ft)}).$mount("#app")}},e={};function s(a){var o=e[a];if(void 0!==o)return o.exports;var i=e[a]={exports:{}};return t[a](i,i.exports,s),i.exports}s.m=t,function(){var t=[];s.O=function(e,a,o,i){if(!a){var l=1/0;for(c=0;c=i)&&Object.keys(s.O).every((function(t){return s.O[t](a[n])}))?a.splice(n--,1):(r=!1,i0&&t[c-1][2]>i;c--)t[c]=t[c-1];t[c]=[a,o,i]}}(),function(){s.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return s.d(e,{a:e}),e}}(),function(){s.d=function(t,e){for(var a in e)s.o(e,a)&&!s.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})}}(),function(){s.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"===typeof window)return window}}()}(),function(){s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}}(),function(){s.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}}(),function(){var t={143:0};s.O.j=function(e){return 0===t[e]};var e=function(e,a){var o,i,l=a[0],r=a[1],n=a[2],d=0;if(l.some((function(e){return 0!==t[e]}))){for(o in r)s.o(r,o)&&(s.m[o]=r[o]);if(n)var c=n(s)}for(e&&e(a);d