import{ar as M,as as R,d as b,q as A,a1 as P,B,ai as x,aa as S,o as C,c as D,_ as U}from "./index-f5e1fd05.js";var _={exports:{}};/*! * * js-audio-recorder - js audio recorder plugin * * @version v1.0.7 * @homepage https://github.com/2fps/recorder * @author 2fps (https://www.zhuyuntao.cn) * @license MIT * */(function(v,w){(function(m,c){v.exports=c()})(M,function(){return function(m){var c={};function d(o){if(c[o])return c[o].exports;var i=c[o]={i:o,l:!1,exports:{}};return m[o].call(i.exports,i,i.exports,d),i.l=!0,i.exports}return d.m=m,d.c=c,d.d=function(o,i,r){d.o(o,i)||Object.defineProperty(o,i,{enumerable:!0,get:r})},d.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},d.t=function(o,i){if(1&i&&(o=d(o)),8&i||4&i&&typeof o=="object"&&o&&o.__esModule)return o;var r=Object.create(null);if(d.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:o}),2&i&&typeof o!="string")for(var t in o)d.d(r,t,(function(e){return o[e]}).bind(null,t));return r},d.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return d.d(i,"a",i),i},d.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)},d.p="",d(d.s=1)}([function(m,c,d){function o(i,r,t){for(var e=0;er?r:t,n=f,l=new ArrayBuffer(44+i.byteLength),u=new DataView(l),g=e,p=0;o(u,p,"RIFF"),p+=4,u.setUint32(p,36+i.byteLength,s),o(u,p+=4,"WAVE"),o(u,p+=4,"fmt "),p+=4,u.setUint32(p,16,s),p+=4,u.setUint16(p,1,s),p+=2,u.setUint16(p,g,s),p+=2,u.setUint32(p,a,s),p+=4,u.setUint32(p,g*a*(n/8),s),p+=4,u.setUint16(p,g*(n/8),s),p+=2,u.setUint16(p,n,s),o(u,p+=2,"data"),p+=4,u.setUint32(p,i.byteLength,s),p+=4;for(var y=0;y44&&e.default.play(n.buffer)},a.prototype.getPlayTime=function(){return e.default.getPlayTime()},a.prototype.pausePlay=function(){!this.isrecording&&this.isplaying&&(this.isplaying=!1,this.onpauseplay&&this.onpauseplay(),e.default.pausePlay())},a.prototype.resumePlay=function(){this.isrecording||this.isplaying||(this.isplaying=!0,this.onresumeplay&&this.onresumeplay(),e.default.resumePlay())},a.prototype.stopPlay=function(){this.isrecording||(this.isplaying=!1,this.onstopplay&&this.onstopplay(),e.default.stopPlay())},a.prototype.destroy=function(){return e.default.destroyPlay(),this.destroyRecord()},a.prototype.getRecordAnalyseData=function(){return this.getAnalyseData()},a.prototype.getPlayAnalyseData=function(){return e.default.getAnalyseData()},a.prototype.getPCM=function(){this.stop();var n=this.getData();return n=t.compress(n,this.inputSampleRate,this.outputSampleRate),t.encodePCM(n,this.oututSampleBits,this.littleEdian)},a.prototype.getPCMBlob=function(){return new Blob([this.getPCM()])},a.prototype.downloadPCM=function(n){n===void 0&&(n="recorder");var l=this.getPCMBlob();r.downloadPCM(l,n)},a.prototype.getWAV=function(){var n=this.getPCM();return t.encodeWAV(n,this.inputSampleRate,this.outputSampleRate,this.config.numChannels,this.oututSampleBits,this.littleEdian)},a.prototype.getWAVBlob=function(){return new Blob([this.getWAV()],{type:"audio/wav"})},a.prototype.downloadWAV=function(n){n===void 0&&(n="recorder");var l=this.getWAVBlob();r.downloadWAV(l,n)},a.prototype.download=function(n,l,u){r.download(n,l,u)},a.prototype.getChannelData=function(){var n=this.getPCM(),l=n.byteLength,u=this.littleEdian,g={left:null,right:null};if(this.config.numChannels===2){var p=new DataView(new ArrayBuffer(l/2)),y=new DataView(new ArrayBuffer(l/2));if(this.config.sampleBits===16)for(var h=0;h{o.value="0",c=new I({sampleBits:16,sampleRate:16e3,numChannels:1}),r(),i()});function i(){d=setInterval(()=>{const f=c.getRecordAnalyseData();Array.from(f).some(a=>a>128)?o.value==="0"?o.value="1":o.value==="2"&&c.resume():o.value==="1"?(c.pause(),o.value="2"):o.value==="2"&&t()},500)}const r=()=>{c.start()};async function t(){o.value="0",clearInterval(d),c.stop();const f=c.getWAVBlob(),s=new FormData;s.append("file",f),o.value="3",e("speakEnd",s)}const e=w;return x(m,()=>e("changeType")),S(()=>{c.destroy()}),(f,s)=>(C(),D("div",{ref_key:"container",ref:m,class:"VoiceAsk"},null,512))}});const E=U(V,[["__scopeId","data-v-50b14db9"]]);export{E as default};