PageSourceSearch

https://fe-static-yuketang.yuketang.cn/fe/static/web/1.2.315/js/2075.81286658.js

js yuketang.cn collected 2026-09-28 09:26:01 UTC 43,561 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkrainweb=self.webpackChunkrainweb||[]).push([["2075"],{87560:function(e,n,t){t.d(n,{IU:function(){return G},oZ:function(){return Y}}),t(13794),t(87481),t(42463),t(42682),t(63649),t(35286),t(20573),t(16446),t(13054),t(88761),t(60668),t(83765),t(86067),t(44959),t(56325),t(61657),t(79136),t(35621),t(72775),t(80764),t(70812),t(33816),t(51054),t(41557),t(32147),t(1080),t(89382),t(63665),t(47210),t(97200),t(19296),t(97127),t(28240),t(76258),t(14087),t(67185),t(1506),t(9032),t(66265),t(38380),t(90171),t(74652),t(45622),t(88218),t(43207),t(19250),t(52042);var o,r,i,s,a,l,c=t(18108);function u(e,n,t,o,r,i,s){try{var a=e[i](s),l=a.value}catch(e){t(e);return}a.done?n(l):Promise.resolve(l).then(o,r)}t(63064),t(80287);function f(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(n){var o;o=t[n],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o})}return e}function d(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function S(){var e=new Date().getTime(),n=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var o=16*Math.random();return e>0?(o=(e+o)%16|0,e=Math.floor(e/16)):(o=(n+o)%16|0,n=Math.floor(n/16)),("x"==t?o:3&o|8).toString(16)})}var h=function(){var e;function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!(this instanceof n))throw TypeError("Cannot call a class as a function");var t=e.APPKey,o=e.token,r=e.taskId,i=e.onmessage,s=e.hooks,a=e.voice;t&&(this.APPKey=t),o&&(this.token=o,this.wssURL="wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1?token="+o),i&&(this._onmessage=i),s&&(this.hooks=s),r?this.taskId=r:this.taskId=S(),this.TTSConfig={voice:a||"mashu",format:"MP3",sample_rate:16e3,volume:100,speech_rate:0,pitch_rate:0,enable_subtitle:!0,platform:"javascript"},this.readyState=-2,this.isConnected=!1,this.isConnecting=!1,this.messageQueue=[],this.init(this.wssURL)}return e=[{key:"_getHeader",value:function(){return{message_id:S(),task_id:this.taskId,namespace:"FlowingSpeechSynthesizer",name:"",appkey:this.APPKey}}},{key:"init",value:function(e){this.connect(e)}},{key:"connect",value:function(e){var n=this;return this.isConnecting||this.isConnected?Promise.resolve():(this.isConnecting=!0,new Promise(function(t,o){var r=new WebSocket(e||n.wssURL);n.socket=r,n.connectResolve=t,n.socket.onopen=function(){n.readyState=1,n.isConnected=!0,n.isConnecting=!1,n.start()},n.socket.onmessage=n.onmessage.bind(n),n.socket.onclose=function(){var e;n.readyState=3,n.isConnected=!1,n.isConnecting=!1,n.socket=null,"function"==typeof(null==(e=n.hooks)?void 0:e.onClose)&&n.hooks.onClose(),console.log("TTS onclose")},n.socket.onerror=function(e){var t;n.readyState=3,console.error("WebSocket Error: ",e),n.socket.close(),n.isConnecting=!1,"function"==typeof(null==(t=n.hooks)?void 0:t.onClose)&&n.hooks.onClose(),o(e)}}))}},{key:"newConnect",value:function(){try{var e=this.socket;e.onopen=null,e.onclose=null,e.onmessage=null,e.close(),console.log("close..."),this.isConnected=!1,this.connect()}catch(e){console.error("newConnect:",e)}}},{key:"sendText",value:function(e){var n=this;return new Promise(function(t,o){if(n.isConnected)if(4===n.readyState){var r=n.socket;if(r&&r.readyState===WebSocket.OPEN){var i={header:d(f({},n._getHeader()),{name:"RunSynthesis"}),payload:{text:e}};r.send(JSON.stringify(i))}}else n.messageQueue.push({message:e,resolve:t,reject:o});else n.messageQueue.push({message:e,resolve:t,reject:o}),n.connect().catch(function(e){return o("Failed to connect: "+e)})})}},{key:"flushMessageQueue",value:function(){for(;this.messageQueue.length>0&&this.isConnected;){var e=this.messageQueue.shift(),n=e.message,t=e.resolve,o=e.reject;try{var r=this.socket;if(r&&r.readyState===WebSocket.OPEN){var i=this._getHeader(),s={header:d(f({},i),{name:"RunSynthesis"}),payload:{text:n}};r.send(JSON.stringify(s))}t("Message sent: "+n)}catch(e){o("Message failed to send: "+n)}}}},{key:"start",value:function(){try{var e=this.socket;if(e&&e.readyState===WebSocket.OPEN){var n=this._getHeader(),t={header:d(f({},n),{name:"StartSynthesis"}),payload:this.TTSConfig};e.send(JSON.stringify(t))}}catch(e){console.error("start failed:",e)}}},{key:"onStartedHandler",value:function(e){var n;this.readyState=4,this.isSynthesisStarted=!0,this.flushMessageQueue(),"function"==typeof this.connectResolve&&(this.connectResolve(),this.connectResolve=null),"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSStart)&&this.hooks.onTTSStart(e)}},{key:"stop",value:function(){try{var e=this.socket;if(e&&e.readyState===WebSocket.OPEN){var n=this._getHeader(),t={header:d(f({},n),{name:"StopSynthesis"})};console.log("发送停止指令",t),e.send(JSON.stringify(t))}}catch(e){console.error("start failed:",e)}}},{key:"onCompletedHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSCompleted)&&this.hooks.onTTSCompleted(e),this.socket.close(),this.isSynthesisStarted=!1}},{key:"onmessage",value:function(e){var n=this;try{var t,o=e.data;if(t=Blob,null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](o):o instanceof t){var r=new FileReader;r.onload=function(){"function"==typeof n._onmessage&&n._onmessage(r.result)},r.readAsArrayBuffer(o)}else if("string"==typeof o){var i=JSON.parse(o),s=i.header,a=i.payload;if(s){var l=s.name,c=s.status;
12e7!==c&&console.error(i),"SynthesisStarted"===l&&this.onStartedHandler(a),"SynthesisCompleted"===l&&this.onCompletedHandler(a),"SentenceBegin"===l&&this.onSentenceBeginHandler(a),"SentenceEnd"===l&&this.onSentenceEndHandler(a),"SentenceSynthesis"===l&&this.onResultChangedHandler(a)}}}catch(e){console.error("onmessage:",e)}}},{key:"onSentenceBeginHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSSentenceBegin)&&this.hooks.onTTSSentenceBegin(e)}},{key:"onSentenceEndHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSSentenceEnd)&&this.hooks.onTTSSentenceEnd(e)}},{key:"onResultChangedHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSResultChanged)&&this.hooks.onTTSResultChanged(e)}},{key:"destroy",value:function(){var e;return(e=function(){var e;return function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var c=[a,l];if(t)throw TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],o=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){try{(e=this.socket).onopen=null,e.onclose=null,e.onmessage=null,e.close(),console.log("close...")}catch(e){console.error("error on close:",e)}return[2]})},function(){var n=this,t=arguments;return new Promise(function(o,r){var i=e.apply(n,t);function s(e){u(i,o,r,s,a,"next",e)}function a(e){u(i,o,r,s,a,"throw",e)}s(void 0)})}).call(this)}}],function(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,e),n}();function v(e,n,t,o,r,i,s){try{var a=e[i](s),l=a.value}catch(e){t(e);return}a.done?n(l):Promise.resolve(l).then(o,r)}var p="ACTION_SYNTHESIS",y=function(){var e;function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!(this instanceof n))throw TypeError("Cannot call a class as a function");var t=e.wssURL,o=e.sessionId,r=e.onmessage,i=e.hooks,s=e.voice;t&&(this.wssURL=t),r&&(this._onmessage=r),i&&(this.hooks=i),o&&(this.sessionId=o),this.TTSConfig={voice:s||"aishuo",format:"MP3",sample_rate:16e3,volume:100,speech_rate:0,pitch_rate:0,enable_subtitle:!0,platform:"javascript"},this.readyState=-2,this.isConnected=!1,this.isConnecting=!1,this.messageQueue=[],this.init(this.wssURL)}return e=[{key:"_getHeader",value:function(){var e,n;return{message_id:(e=new Date().getTime(),n=performance&&performance.now&&1e3*performance.now()||0,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var o=16*Math.random();return e>0?(o=(e+o)%16|0,e=Math.floor(e/16)):(o=(n+o)%16|0,n=Math.floor(n/16)),("x"==t?o:3&o|8).toString(16)})),task_id:this.taskId,namespace:"FlowingSpeechSynthesizer",name:"",appkey:this.APPKey}}},{key:"init",value:function(e){this.connect(e)}},{key:"connect",value:function(e){var n=this;return this.isConnecting||this.isConnected?Promise.resolve():(this.isConnecting=!0,new Promise(function(t,o){var r=new WebSocket(e||n.wssURL);n.socket=r,n.connectResolve=t,n.socket.onopen=function(){n.readyState=1,n.isConnected=!0,n.isConnecting=!1},n.socket.onmessage=n.onmessage.bind(n),n.socket.onclose=function(){var e;n.readyState=3,n.isConnected=!1,n.isConnecting=!1,n.socket=null,"function"==typeof(null==(e=n.hooks)?void 0:e.onClose)&&n.hooks.onClose(),console.log("TTS onclose")},n.socket.onerror=function(e){var t;n.readyState=3,console.error("WebSocket Error: ",e),n.socket.close(),n.isConnecting=!1,"function"==typeof(null==(t=n.hooks)?void 0:t.onClose)&&n.hooks.onClose(),o(e)}}))}},{key:"newConnect",value:function(){try{var e=this.socket;e.onopen=null,e.onclose=null,e.onmessage=null,e.close(),console.log("close..."),this.isConnected=!1,this.connect()}catch(e){console.error("newConnect:",e)}}},{key:"sendText",value:function(e){var n=this;return new Promise(function(t,o){if(n.isConnected)if(4===n.readyState){var r=n.socket;if(r&&r.readyState===WebSocket.OPEN){var i=n._getHeader(),s={session_id:n.sessionId,message_id:i.message_id,action:p,data:e};r.send(JSON.stringify(s))}}else n.messageQueue.push({message:e,resolve:t,reject:o});else n.messageQueue.push({message:e,resolve:t,reject:o}),n.connect().catch(function(e){return o("Failed to connect: "+e)})})}},{key:"flushMessageQueue",value:function(){for(;this.messageQueue.length>0&&this.isConnected;){var e=this.messageQueue.shift(),n=e.message,t=e.resolve,o=e.reject;try{var r=this.socket;if(r&&r.readyState===WebSocket.OPEN){var i=this._getHeader(),s={session_id:this.sessionId,message_id:i.message_id,action:p,data:n};r.send(JSON.stringify(s))}t("Message sent: "+n)}catch(e){o("Message failed to send: "+n)}}}},{key:"start",value:function(){try{var e=this.socket;if(e&&e.readyState===WebSocket.OPEN){var n,t,o=this._getHeader(),r
1={header:(n=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(n){var o;o=t[n],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o})}return e}({},o),t={name:p},t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t})(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))}),n),payload:this.TTSConfig};e.send(JSON.stringify(r))}}catch(e){console.error("start failed:",e)}}},{key:"onStartedHandler",value:function(e){var n;this.readyState=4,this.isSynthesisStarted=!0,this.flushMessageQueue(),"function"==typeof this.connectResolve&&(this.connectResolve(),this.connectResolve=null),"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSStart)&&this.hooks.onTTSStart(e)}},{key:"stop",value:function(){try{var e=this.socket;if(e&&e.readyState===WebSocket.OPEN){var n=this._getHeader(),t={session_id:this.sessionId,message_id:n.message_id,action:"ACTION_COMPLETE",data:""};e.send(JSON.stringify(t))}}catch(e){console.error("start failed:",e)}}},{key:"onCompletedHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSCompleted)&&(e&&(e.taskId=this.taskId),this.hooks.onTTSCompleted(e)),this.socket.close(),this.isSynthesisStarted=!1}},{key:"onmessage",value:function(e){var n=this;try{var t,o=e.data;if(t=Blob,null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](o):o instanceof t){var r=new FileReader;r.onload=function(){"function"==typeof n._onmessage&&n._onmessage(r.result)},r.readAsArrayBuffer(o)}else if("string"==typeof o){var i=JSON.parse(o),s=i.code,a=(i.message,i.ready),l=i.final,c=i.result;if(s)return void console.error(i);a&&this.onStartedHandler(c),c&&this.onResultChangedHandler(c),l&&this.onCompletedHandler(c)}}catch(e){console.error("onmessage:",e)}}},{key:"onSentenceBeginHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSSentenceBegin)&&this.hooks.onTTSSentenceBegin(e)}},{key:"onSentenceEndHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSSentenceEnd)&&this.hooks.onTTSSentenceEnd(e)}},{key:"onResultChangedHandler",value:function(e){var n;"function"==typeof(null==(n=this.hooks)?void 0:n.onTTSResultChanged)&&this.hooks.onTTSResultChanged(e)}},{key:"destroy",value:function(){var e;return(e=function(){var e;return function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var c=[a,l];if(t)throw TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],o=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){try{(e=this.socket).onopen=null,e.onclose=null,e.onmessage=null,e.close(),console.log("close...")}catch(e){console.error("error on close:",e)}return[2]})},function(){var n=this,t=arguments;return new Promise(function(o,r){var i=e.apply(n,t);function s(e){v(i,o,r,s,a,"next",e)}function a(e){v(i,o,r,s,a,"throw",e)}s(void 0)})}).call(this)}}],function(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,e),n}
1(),g=t(85369),T=t(1948),E=t(21208),m=t(73121),b=t(48977);t(27281),t(32927),t(35130),t(74624);var k=t(24530);function O(e){return new TextDecoder().decode(e)}function _(e){return new TextEncoder().encode(e)}var C=((o={})[o.PROTOCOL_VERSION=1]="PROTOCOL_VERSION",o[o.DEFAULT_HEADER_SIZE=1]="DEFAULT_HEADER_SIZE",o[o.PROTOCOL_VERSION_BITS=4]="PROTOCOL_VERSION_BITS",o[o.HEADER_BITS=4]="HEADER_BITS",o[o.MESSAGE_TYPE_BITS=4]="MESSAGE_TYPE_BITS",o[o.MESSAGE_TYPE_SPECIFIC_FLAGS_BITS=4]="MESSAGE_TYPE_SPECIFIC_FLAGS_BITS",o[o.MESSAGE_SERIALIZATION_BITS=4]="MESSAGE_SERIALIZATION_BITS",o[o.MESSAGE_COMPRESSION_BITS=4]="MESSAGE_COMPRESSION_BITS",o[o.RESERVED_BITS=8]="RESERVED_BITS",o[o.EVENT_NUMBER_BYTES=4]="EVENT_NUMBER_BYTES",o[o.PAYLOAD_SIZE_BYTES=4]="PAYLOAD_SIZE_BYTES",o[o.CLIENT_FULL_REQUEST=1]="CLIENT_FULL_REQUEST",o[o.CLIENT_AUDIO_ONLY_REQUEST=2]="CLIENT_AUDIO_ONLY_REQUEST",o[o.SERVER_FULL_RESPONSE=9]="SERVER_FULL_RESPONSE",o[o.SERVER_ACK=11]="SERVER_ACK",o[o.SERVER_ERROR_RESPONSE=15]="SERVER_ERROR_RESPONSE",o[o.NO_SEQUENCE=0]="NO_SEQUENCE",o[o.POS_SEQUENCE=1]="POS_SEQUENCE",o[o.NEG_WITHOUT_SEQUENCE=2]="NEG_WITHOUT_SEQUENCE",o[o.NEG_WITH_SEQUENCE=3]="NEG_WITH_SEQUENCE",o[o.MESSAGE_WITH_EVENT=4]="MESSAGE_WITH_EVENT",o[o.NO_SERIALIZATION=0]="NO_SERIALIZATION",o[o.JSON=1]="JSON",o[o.THRIFT=3]="THRIFT",o[o.CUSTOM_TYPE=15]="CUSTOM_TYPE",o[o.NO_COMPRESSION=0]="NO_COMPRESSION",o[o.GZIP=1]="GZIP",o[o.CUSTOM_COMPRESSION=15]="CUSTOM_COMPRESSION",o),I=((r={})[r.CLIENT_FULL_REQUEST=1]="CLIENT_FULL_REQUEST",r[r.CLIENT_AUDIO_ONLY_REQUEST=2]="CLIENT_AUDIO_ONLY_REQUEST",r[r.SERVER_FULL_RESPONSE=9]="SERVER_FULL_RESPONSE",r[r.SERVER_AUDIO_ONLY_RESPONSE=11]="SERVER_AUDIO_ONLY_RESPONSE",r[r.SERVER_ERROR_RESPONSE=15]="SERVER_ERROR_RESPONSE",r),w=((i={})[i.StartConnection=1]="StartConnection",i[i.FinishConnection=2]="FinishConnection",i[i.StartSession=100]="StartSession",i[i.FinishSession=102]="FinishSession",i[i.TaskRequest=200]="TaskRequest",i),P=((s={})[s.ConnectionStarted=50]="ConnectionStarted",s[s.ConnectionFailed=51]="ConnectionFailed",s[s.ConnectionFinished=52]="ConnectionFinished",s[s.SessionStarted=150]="SessionStarted",s[s.SessionCanceled=151]="SessionCanceled",s[s.SessionFinished=152]="SessionFinished",s[s.SessionFailed=153]="SessionFailed",s[s.TTSSentenceStart=350]="TTSSentenceStart",s[s.TTSSentenceEnd=351]="TTSSentenceEnd",s[s.TTSResponse=352]="TTSResponse",s);t(10381);var x=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:C.MESSAGE_WITH_EVENT,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C.CLIENT_FULL_REQUEST,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.PROTOCOL_VERSION,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:C.JSON,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:C.NO_COMPRESSION,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:new ArrayBuffer(0),a=new DataView(new ArrayBuffer(4)),l=Math.trunc(s.byteLength/4)+1;return a.setUint8(0,t<<4|l),a.setUint8(1,n<<4|e),a.setUint8(2,o<<4|r),a.setUint8(3,i),a},R=function(e,n){var t=_(null!=n&&n.payload?JSON.stringify(n.payload):"{}"),o=x(),r=null!=n&&n.session_id?4+_(n.session_id).byteLength:0,i=new ArrayBuffer(o.byteLength+C.EVENT_NUMBER_BYTES+r+C.PAYLOAD_SIZE_BYTES+t.byteLength),s=new DataView(i),a=0;if(s.setUint32(a,o.getUint32(0,!1),!1),a+=4,s.setUint32(4,e,!1),a+=4,null!=n&&n.session_id){var l=_(n.session_id);s.setUint32(a,l.byteLength,!1),new Uint8Array(i,a+=4).set(l),a+=l.length}return s.setUint32(a,t.length,!1),new Uint8Array(i,a+=4).set(t),new Blob([i])};function N(e){try{return JSON.parse(e)}catch(e){console.log(e);return}}function A(e,n,t,o,r,i,s){try{var a=e[i](s),l=a.value}catch(e){t(e);return}a.done?n(l):Promise.resolve(l).then(o,r)}var L=t(66146);function U(e,n,t,o,r,i,s){try{var a=e[i](s),l=a.value}catch(e){t(e);return}a.done?n(l):Promise.resolve(l).then(o,r)}var D=function(){var e;function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!(this instanceof n))throw TypeError("Cannot call a class as a function");this.sampleRate=e.sampleRate||16e3,this.onMessage=e.onmessage||function(){},this.hooks=e.hooks||{onTTSStart:function(){},onTTSCompleted:function(){},onTTSSentenceBegin:function(){},onTTSSentenceEnd:function(){},onTTSResultChanged:function(){},onClose:function(){}},this.isServerError=!1,this.isInService=!1,this.status=n.STATUS.IDLE,this.textQueue=[],this.client=null,this.speaker=e.voice||"zh_male_lengkugege_emo_v2_mars_bigtts",this.token=e.token,this.appkey=e.APPKey,this.resourceId=e.isDoubaoCloneVoice?"volc.megatts.default":"volc.service_type.10029",this.textQueueSending=!1,this.timer=null,this.currentTime=0,this.debug=!1,this.finishImmediately=!1,this.getFirstMessage=!1,this.init()}return e=[{key:"connect",value:function(){var e;return(e=function(){var e,t,o,r;return function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]}
1,trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var c=[a,l];if(t)throw TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],o=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(i){if(e=this,console.log("[Hook] Connecting..."),!this.appkey||!this.token)return(0,L.F)("请先配置 Doubao TTS 相关参数"),[2];this.client&&this.destroy(),this.client=function(){var e={audioBuffers:[],socket:void 0,sessionId:"",sessionConfig:{},sessionStarted:!1};function n(){return e.sessionId?4+_(e.sessionId).byteLength:0}return Object.freeze({start:function(t){var o=t.url,r=t.config,i=t.onStart,s=t.onMessage,a=t.onClose,l=t.onError,c=t.onWSError,u=(t.getSentences,t.onSessionStarted),f=t.onTTSSentenceStart,d=t.onTTSSentenceEnd,S=t.onSessionFinished,h=t.onConnectionFinished,v=t.debug,p=void 0!==v&&v,y=new WebSocket(o);e.socket=y,y.onopen=function(){p&&console.info("connected"),y.send(R(w.StartConnection)),null==i||i()},y.onmessage=function(t){var o;return(o=function(){var o,i,a,c,v,p,g,T,E,m,b,_,x,A,L,U,D,M,j,B,F,H,G,Q,Y,V;return function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var c=[a,l];if(t)throw TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],o=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(Z){var W,J,K,q;switch(Z.label){case 0:if(W=t.data,null!=(J=Blob)&&"undefined"!=typeof Symbol&&J[Symbol.hasInstance]?!J[Symbol.hasInstance](W):!(W instanceof J))return[3,2];return o=0,[4,t.data.arrayBuffer()];case 1:if((a=new DataView(i=Z.sent())).getUint8(0),a.getUint8(0),c=a.getUint8(1)>>4,v=15&a.getUint8(1),a.getUint8(2),a.getUint8(2),a.getUint8(3),o+=4,c===I.SERVER_FULL_RESPONSE||c===I.SERVER_AUDIO_ONLY_RESPONSE)if(v===C.MESSAGE_WITH_EVENT)if(p=a.getUint32(o),o+=4,console.log("server eventName:",null!=(K=null!=(q=w[p])?q:P[p])?K:"UnknownEvent"),p===P.ConnectionStarted)e.sessionId=URL.createObjectURL(new Blob).slice(-36),e.sessionConfig=(0,k.cloneDeep)(r),y.send(R(w.StartSession,{payload:e.sessionConfig,session_id:e.sessionId}));else if(p===P.SessionStarted)e.sessionStarted=!0,null==u||u();else if(p===P.TTSResponse)c===I.SERVER_AUDIO_ONLY_RESPONSE?(new DataView(g=i.slice(o+n())).getUint32(0),T=g.slice(4),e.audioBuffers.push(T),null==s||s(T)):console.log("不支持的TTSResponse");else if(p===P.TTSSentenceStart)E=O(i.slice(o+n()+4)),null==f||f(N(E));else if(p===P.TTSSentenceEnd)m=O(i.slice(o+n()+4)),null==d||d(N(m));else if([P.SessionFinished,P.SessionCanceled,P.SessionFailed].includes(p))try{p===P.SessionFinished&&(null==S||S()),b=i.slice(o+n()+4),_=O(b),A=(x=JSON.parse(_)).status_code,L=x.message,2e7!==A&&(null==l||l({msg:L,code:A}))}catch(e){console.log("Session error:",e),null==l||l()}else if(p===P.ConnectionFailed){U=i.slice(o+8);try{D=O(U),j=(M=JSON.parse(D)).status_code,B=M.message,2e7!==j&&(null==l||l({msg:B,code:j}))}catch(e){console.log("ConnectionFailed error:",e),null==l||l()}}else p===P.ConnectionFinished&&(null==h||h());else console.log("unable to handle unknown messageFlag",v);else if(c===I.SERVER_ERROR_RESPONSE)try{F=i.slice(o+n()),o+=4,H=F.slice(4),G=O(H),Y=(Q=JSON.parse(G)).status_code,V=Q.message,null==l||l({msg:V,code:Y})}catch(e){console.log("server error response:",e),null==l||l()}else console.log("unable to handle messageType:",c);Z.label=2;case 2:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(t,r){var i=o.apply(e,n);function s(e){A(i,t,r,s,a,"next",e)}function a(e){A(i,t,r,s,a,"throw",e)}s(void 0)})})()}
1,y.onclose=function(){p&&console.info("disconnected"),null==a||a()},y.onerror=function(e){return null==c?void 0:c(e)}},close:function(){var n;null==(n=e.socket)||n.close()},sendText:function(n){if(e.sessionStarted){var t,o=(0,k.merge)(e.sessionConfig,{req_params:{text:n}});null==(t=e.socket)||t.send(R(w.TaskRequest,{payload:o,session_id:e.sessionId}))}},finishSession:function(){var n;null==(n=e.socket)||n.send(R(w.FinishSession,{session_id:e.sessionId}))},finishConnection:function(){var n;null==(n=e.socket)||n.send(R(w.FinishConnection))}})}(),console.log("[Hook] client created"),this.reset(),this.status=n.STATUS.CONNECTING,console.log("[Hook] Connecting to URL:",t=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=[];for(var o in n)t.push("".concat(o,"=").concat(encodeURIComponent(n[o])));return"".concat(e,"?").concat(t.join("&"))}("wss://openspeech.bytedance.com/api/v3/tts/bidirection",{api_resource_id:this.resourceId,api_app_key:this.appkey||"",api_access_key:this.token?"Jwt; ".concat(this.token):""}));try{this.client.start({debug:this.debug,url:t,config:{user:{uid:"vue-hook-user"},namespace:"BidirectionalTTS",req_params:{speaker:this.speaker,audio_params:{format:"mp3",sample_rate:this.sampleRate}}},onStart:function(){var n,t;e.isServerError=!1,e.isInService=!0,null==(n=(t=e.hooks).onTTSStart)||n.call(t)},onMessage:function(n){e.getFirstMessage||(console.log("[Hook] Received message:",(Date.now()-e.currentTime)/1e3),e.getFirstMessage=!0),e.onMessage(n)},onSessionStarted:function(){var t,o;e.status=n.STATUS.CONNECTED,e.textQueueSend(),null==(t=(o=e.hooks).onTTSSentenceBegin)||t.call(o)},onError:function(){var n,t;e.isServerError=!0,e.isInService=!1,null==(n=(t=e.hooks).onTTSError)||n.call(t)},onClose:function(){var t,o;e.isInService=!1,null==(t=(o=e.hooks).onClose)||t.call(o),e.status=n.STATUS.CLOSED},onTTSSentenceEnd:function(){var t,o;null==(t=(o=e.hooks).onTTSSentenceEnd)||t.call(o),e.timer&&(clearTimeout(e.timer),e.timer=null),e.textQueue.length>0||(e.timer=setTimeout(function(){var t,o;e.timer=null,null==(t=(o=e.hooks).onTTSCompleted)||t.call(o),e.status!==n.STATUS.CLOSED&&(e.client.finishSession(),e.client.finishConnection(),e.status=n.STATUS.CLOSED)},6e3))},onSessionFinished:function(){}})}catch(e){console.log("[Hook] Error connecting:",e),this.destroy(),null==(o=(r=this.hooks).onClose)||o.call(r)}return[2]})},function(){var n=this,t=arguments;return new Promise(function(o,r){var i=e.apply(n,t);function s(e){U(i,o,r,s,a,"next",e)}function a(e){U(i,o,r,s,a,"throw",e)}s(void 0)})}).call(this)}},{key:"reset",value:function(){this.isServerError=!1,this.textQueue=[]}},{key:"textQueueSend",value:function(){if(!this.textQueueSending&&this.status===n.STATUS.CONNECTED&&this.textQueue.length>0){for(this.textQueueSending=!0;this.textQueue.length>0;){var e=this.textQueue.shift();e&&this.client&&this.client.sendText(e)}this.textQueueSending=!1}}},{key:"sendText",value:function(e){0===this.currentTime&&(this.currentTime=Date.now()),"string"==typeof e&&""!==e.trim()&&(this.textQueue.push(e),this.textQueueSend())}},{key:"stop",value:function(){var e;this.client&&(null==(e=this.client)||e.finishSession(),this.finishImmediately=!0)}},{key:"init",value:function(){try{this.connect()}catch(e){console.log("[Hook] Error initializing:",e)}}},{key:"destroy",value:function(){this.stop(),this.timer&&(clearTimeout(this.timer),this.timer=null),this.client&&(this.client.finishConnection(),this.client=null)}}],function(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,e),n}();function M(e,n,t,o,r,i,s){try{var a=e[i](s),l=a.value}catch(e){t(e);return}a.done?n(l):Promise.resolve(l).then(o,r)}function j(e){return function(){var n=this,t=arguments;return new Promise(function(o,r){var i=e.apply(n,t);function s(e){M(i,o,r,s,a,"next",e)}function a(e){M(i,o,r,s,a,"throw",e)}s(void 0)})}}function B(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);
1"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(n){var o;o=t[n],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o})}return e}function F(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function H(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var c=[a,l];if(t)throw TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,o=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],o=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}l={IDLE:"idle",CONNECTING:"connecting",CONNECTED:"connected",CLOSED:"closed"},(a="STATUS")in D?Object.defineProperty(D,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):D[a]=l;function G(e){var n,t=(0,c.ref)(null),o=(0,c.ref)(Q.UNINITIALIZED),r=null,i=(0,c.ref)(!1),s=null,a=null,l=(0,c.ref)(null),u=[],f=null,d=null,S=[],v=!1,p=(0,c.ref)(!0),k=null,O=(0,c.ref)({playPerm:!0,playToggle:!1,playState:Y.UNPLAYED,playRecord:null}),_=/iP(hone|od|ad)/.test(navigator.userAgent)||/^((?!chrome|android).)*safari/i.test(navigator.userAgent),C=null,I=!1,w=[],P=!1,x=0,R=0,N=null;function A(e){var n="/api/v3/third-capability/flowing-speech/get-token";return e&&(n="/api/v3/third-capability/flowing-speech/get-token?type=".concat(e)),m.ZP.post(n,{}).then(function(e){if(e&&0===e.code&&e.data){var n=e.data,o=n.taskId,r=n.token,i=n.appkey;return t.value=Object.assign(t.value||{},{APPKey:i,taskId:o,token:r}),e.data}return console.error("getTTSToken:",e),null}).catch(function(e){return console.error("getTTSToken:",e),null})}function L(e){return j(function(){var n,o,i,s,a;return H(this,function(l){switch(l.label){case 0:var c,u,f,d;if(i=null==(n=t.value)?void 0:n.isDoubaoTTS,e)return[3,6];if((null==(s=t.value)?void 0:s.rpg__custom_voice)!=="tencent")return[3,2];return[4,(d={Action:"TextToStreamAudioWSv2",Codec:"mp3",EnableSubtitle:"True",SampleRate:16e3,SessionId:(u=new Date().getTime(),f=performance&&performance.now&&1e3*performance.now()||0,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=16*Math.random();return u>0?(n=(u+n)%16|0,u=Math.floor(u/16)):(n=(f+n)%16|0,f=Math.floor(f/16)),("x"==e?n:3&n|8).toString(16)})),Speed:0,VoiceType:2e8,FastVoiceType:(null==(c=t.value)?void 0:c.voice)||"WCHN-e8035718788b4443a88c7088952cbd6e",Volume:0},m.ZP.post("/api/v3/third-capability/flowing-speech/tencent-flowing-speech-sign",d).then(function(e){if(e&&0===e.code&&e.data){var n=e.data.url;return t.value=Object.assign(t.value||{},{wssUrl:n,sessionId:d.SessionId}),e.data}return console.error("getTTSTokenTX:",e),null}).catch(function(e){return console.error("getTTSTokenTX:",e),null}))];case 1:case 3:return e=l.sent(),[3,6];case 2:if(!i)return[3,4];return[4,A(2)];case 4:return[4,A()];case 5:e=l.sent(),l.label=6;case 6:return r=(null==(o=t.value)?void 0:o.rpg__custom_voice)?new y(F(B({},t.value),{wssURL:(null==e?void 0:e.url)||"wss://tts.tencentcloudapi.com/",sessionId:(null==(a=t.value)?void 0:a.sessionId)||"",onmessage:es,hooks:{onTTSStart:en,onTTSCompleted:et,onTTSSentenceBegin:eo,onTTSSentenceEnd:er,onTTSResultChanged:ei,onClose:ea}})):i?new D(F(B({},t.value),{onmessage:es,hooks:{onTTSStart:en,onTTSCompleted:et,onTTSSentenceBegin:eo,onTTSSentenceEnd:er,onClose:ea}})):new h(F(B({},t.value),{APPKey:(null==e?void 0:e.APPKey)||"0RAPnHRgkDLNXQht",token:(null==e?void 0:e.token)||"66c5ca71cab94159a6f25f1c5fc8ea64",format:"mp3",taskId:null,onmessage:es,hooks:{onTTSStart:en,onTTSCompleted:et,onTTSSentenceBegin:eo,onTTSSentenceEnd:er,onTTSResultChanged:ei,onClose:ea}})),[2]}})})()}function U(){return console.log("initPlayer"),new Promise(function(e,n){if(l.value)if(_){z(),C&&"closed"!==C.state||(C=new(window.AudioContext||window.webkitAudioContext),I=!1),L();try{l.value.play()}catch(e){console.log("initPlayer error",e)}finally{f=e,G(l.value),e()}}else s=M(),l.value.src=URL.createObjectURL(s),s.addEventListener("sourceopen",function(){a=s.addSourceBuffer("audio/mpeg"),L(),l.value.play(),f=e,O.value.playState=Y.PLAYING}),d=setTimeout(function(){e(),f=null},500),G(l.value);else n({code:-1})})}function M(){return window.ManagedMediaSource?new window.ManagedMediaSource:window.MediaSource?new window.MediaSource:void console.error("No MediaSource API available")}function G(e){e&&(e.addEventListener("ended",Z),e.addEventListener("pause",W),e.addEventListener("play",V),e.addEventListener("playing",V),e.addEventListener("timeupdate",J))}function V(){console.log("onPlay")}function Z(){return j(function(){var n;return H(this,function(t){switch(t.label){case 0:return n=b.QX.deepClone(O.value.playRecord),g.Z.emit(T.GM.TTS_PLAY_FULL_ENDED,{record:n}),O.value.playState=Y.END,[4,(0,c.nextTick)()];case 1:return t.sent(),W(),(null==e?void 0:e.onEnded)&&e.onEnded(),[2]}})})()}function W(){return j(function(){return H(this,function(e){return O.value.playState=Y.UNPLAYED,[2]})})()}function J(){g.Z.emit(T.GM.TTS_TIMEUPDATE,{command:"TTSPlayTimeupdate",val:{currentTime:this.currentTime}})}function K(){if(C&&!I){var e=C.currentTime-R,n=x+Math.max(0,e);g.Z.emit(T.GM.TTS_TIMEUPDATE,{command:"TTSPlayTimeupdate",val:{currentTime:n}})}}function q(){N&&(clearInterval(N),N=null)}function z(){x=0,R=0,q()}function X(){return j(function(){var e;return H(this,function(n){try{r&&i.value&&(S&&S.length?(k&&(clearTimeout(k),k=null),v||(v=!0,e=S.shift(),$(e))):p.value||(k=setTimeout(function(){ee()},1e3)))}catch(e){console.error(e)}return[2]})})()}function $(e){return j(function(){return H(this,function(n){return r&&i.value&&"string"==typeof e&&(r.sendText(e),v=!1,X()),[2]})})()}function ee(){ef()}function en(){i.value=!0,o.value=Q.STARTED,"function"==typeof f&&(clearTimeout(d),f(),f=null),!_&&s&&a.addEventListener("updateend",el),X(),console.log("语音合成已开始")}function et(){i.value=!1,o.value=Q.CLOSED,S.length&&(S=[]),k&&(clearTimeout(k),k=null),console.log("语音合成已结束")}function eo(){}function er(e){}
1function ei(e){if(e){var n=e.subtitles;(null==n?void 0:n.length)>0&&function(e){if(null==e?void 0:e.length){var n=e.map(function(e){var n=e.text,t=e.begin_index,o=e.begin_time,r=e.Text,i=e.BeginTime,s=e.BeginIndex;return{text:n||(void 0===r?"":r),index:t||(void 0===s?0:s),begin:o||(void 0===i?0:i)}});g.Z.emit(T.GM.UPDATE_TTS_SUBTITLES,{command:"TTSPlaySubtitles",val:{subtitles:n}})}}(n)}}function es(e){_?(w.push(e),I||n||ec()):(u.push(e),el())}function ea(){_||s&&s.endOfStream(),i.value&&(i.value=!1,o.value=Q.CLOSED,S.length&&(S=[])),O.value.playToggle||l.value.pause()}function el(){u.length>0&&!a.updating&&a.appendBuffer(u.shift())}function ec(){if(C&&0!==w.length&&!I&&!n&&!P){var e,t=w.reduce(function(e,n){return e+n.byteLength},0);if(0===t)return void console.warn("iOS Audio Queue: No data to process");var o=new Uint8Array(t),r=0,i=!0,s=!1,a=void 0;try{for(var l,c=w[Symbol.iterator]();!(i=(l=c.next()).done);i=!0){var u=l.value;u&&u.byteLength>0&&(o.set(new Uint8Array(u),r),r+=u.byteLength)}}catch(e){s=!0,a=e}finally{try{i||null==c.return||c.return()}finally{if(s)throw a}}w=[],e=o.buffer,"suspended"===C.state?C.resume().then(function(){eu(e)}).catch(function(n){console.error("Failed to resume audio context",n),w.push(e)}):eu(e)}}function eu(e){P=!0,C.decodeAudioData(e.slice(0),function(e){(n=C.createBufferSource()).buffer=e,n.connect(C.destination),n.start(0),O.value.playState=Y.PLAYING,R=C.currentTime,q(),N=setInterval(K,200),n.onended=function(){try{if(!n)return;x+=e.duration,q(),P=!1,w.length>0?requestAnimationFrame(function(){ec()}):(O.value.playState=Y.UNPLAYED,Z()),n&&(n.disconnect(),n.onended=null,n=null)}catch(e){console.log(e)}}},function(t){console.error("decodeAudioData error",t),n=null,P=!1,w.push(e),requestAnimationFrame(function(){ec()})})}function ef(){r&&i.value?r.stop():setTimeout(function(){null==r||r.stop()},500)}function ed(e){var t=O.value||{},o=t.playState,r=t.playRecord;if(o===Y.PLAYING){if(ef(),l.value&&l.value.pause(),O.value.playState=Y.PAUSE,O.value.playToggle=!1,_){if(z(),I=!0,P=!1,w=[],n){try{n.stop()}catch(e){console.error("Error stopping audioBufferSource:",e)}n=null}if(C&&"running"===C.state)try{C.suspend()}catch(e){console.error("Error suspending audioContext:",e)}}e?g.Z.emit(T.GM.AI_ASSISTANT,{command:"TTSAudioPlayStop",val:F(B({},e),{playState:Y.PAUSE})}):r&&g.Z.emit(T.GM.AI_ASSISTANT,{command:"TTSAudioPlayStop",val:F(B({},r),{playState:Y.PAUSE})}),console.log("停止语音播放:",e)}n&&(n.onended=null)}return{isStream:p,TTSState:o,TTSConfig:t,playerRef:l,isSynthesisStarted:i,TTSAudioPlayConfig:O,initTTS:function(){return j(function(){var e,n,t=arguments;return H(this,function(s){switch(s.label){case 0:if(e=t.length>0&&void 0!==t[0]?t[0]:{},o.value===Q.INITIALIZING)return[2,!1];return e&&(n=e.container)&&(l.value=n),function(){if(z(),r){try{var e;r.hooks={},null==(e=r.destroy)||e.call(r)}catch(e){console.error("detachSynthesizer:",e)}r=null,i.value=!1,v=!1,u=[],w=[],S.length&&(S=[]),k&&(clearTimeout(k),k=null)}}(),o.value=Q.INITIALIZING,S.length&&(S=[]),[4,U()];case 1:return s.sent(),[2]}})}).apply(this,arguments)},initPlayer:U,setPlayer:function(){if(console.log("setPlayer"),l.value){if(S.length&&(S=[]),_){C&&"closed"!==C.state||(C=new(window.AudioContext||window.webkitAudioContext),I=!1);return}"open"!==s.readyState&&(s=M(),l.value.src=URL.createObjectURL(s),s.addEventListener("sourceopen",function(){a=s.addSourceBuffer("audio/mpeg"),l.value.play(),O.value.playState=Y.PLAYING,console.log("setPlayer sourceopen")}))}},execTTSTask:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return j(function(){var t,o,r,i,s,a,l;return H(this,function(c){if(p.value=n,"string"==typeof e){if((e=(e=(e=(0,E.YH)(e)).replace(/[\u200B-\u200F\uFEFF]/g,"")).replace(/\s+/g," ")).length<300)e.trim()&&S.push(e.trim());else{t=e.replace(/\r?\n/g,"\n").split("\n").filter(Boolean),o=!0,r=!1,i=void 0;try{for(s=t[Symbol.iterator]();!(o=(a=s.next()).done);o=!0)(l=a.value)&&l.trim()&&S.push(l.trim())}catch(e){r=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(r)throw i}}}X()}return[2]})})()},sendData:$,stopSST:ef,stopSynthesis:ee,toggleTTSAudioPlay:function(e){if(e){var n=e.enable,t=e.playState;n?(g.Z.emit(T.GM.CHAT_OPEN_TTSAudioPlay,{command:"TTSAudioPlayStart",val:{playState:Y.PLAYING}}),O.value.playToggle=!0,_&&(I=!1,w=[],C&&"closed"!==C.state?"suspended"===C.state&&C.resume():C=new(window.AudioContext||window.webkitAudioContext))):(O.value.playToggle=!1,t===Y.PLAYING&&ed())}},stopAudioPlay:ed,toggleAudioPlay:function(e){l.value&&(e===Y.PLAYING?O.value.playToggle&&(l.value.play().catch(function(){}),O.value.playState=Y.PLAYING):e===Y.PAUSE&&(l.value.pause(),O.value.playState=Y.PAUSE))},destroyTTS:function(){var e;if(ef(),l.value&&(e=l.value)&&(e.removeEventListener("ended",Z),e.removeEventListener("pause",W),e.removeEventListener("play",V),e.removeEventListener("playing",V),e.removeEventListener("timeupdate",J)),_){if(z(),I=!0,P=!1,w=[],n){try{n.stop()}catch(e){console.error("Error stopping audioBufferSource:",e)}n=null}if(C){try{C.close()}catch(e){console.error("Error closing audioContext:",e)}C=null}}},stopCurrentAudioPlay:function(e){var t=O.value||{},o=t.playState,r=t.playRecord;if(o===Y.PLAYING){if(ef(),l.value&&(l.value.pause(),l.value.src=""),O.value.playState=Y.PAUSE,_){if(z(),I=!0,P=!1,w=[],n){try{n.stop()}catch(e){console.error("Error stopping audioBufferSource:",e)}n.disconnect(),n=null}if(C){try{"closed"!==C.state&&("running"===C.state&&C.suspend(),C.close())}catch(e){console.error("Error closing audioContext:",e)}C=null}}e?g.Z.emit(T.GM.AI_ASSISTANT,{command:"TTSAudioPlayStop",val:F(B({},e),{playState:Y.PAUSE})}):r&&g.Z.emit(T.GM.AI_ASSISTANT,{command:"TTSAudioPlayStop",val:F(B({},r),{playState:Y.PAUSE})}),console.log("停止语音播放:",e)}n&&(n.onended=null)}}}var Q={UNINITIALIZED:-1,INITIALIZING:0,STARTED:2,CLOSED:3},Y={UNPLAYED:0,PLAYING:1,PAUSE:2,END:3}},10381:function(e,n,t){t(39409)({target:"Math",stat:!0},{trunc:t(77789)})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.