21ca3e9f6b3b54eb2966439406134c4dc63df3535bc145dd2f70b578ae8eba03.json 6.6 KB

1
  1. {"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.SynthesisRestAdapter = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../sdk/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\n/**\n * Implements methods for speaker recognition classes, sending requests to endpoint\n * and parsing response into expected format\n * @class SynthesisRestAdapter\n */\nclass SynthesisRestAdapter {\n constructor(config, authentication) {\n let endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Endpoint, undefined);\n if (!endpoint) {\n const region = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Region, \"westus\");\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Host, `https://${region}.tts.speech${hostSuffix}`);\n }\n this.privUri = `${endpoint}/cognitiveservices/voices/list`;\n const options = Exports_js_1.RestConfigBase.requestOptions;\n this.privRestAdapter = new Exports_js_1.RestMessageAdapter(options);\n this.privAuthentication = authentication;\n }\n /**\n * Sends list voices request to endpoint.\n * @function\n * @public\n * @param connectionId - guid for connectionId\n * @returns {Promise<IRestResponse>} rest response to status request\n */\n getVoicesList(connectionId) {\n this.privRestAdapter.setHeaders(HeaderNames_js_1.HeaderNames.ConnectionId, connectionId);\n return this.privAuthentication.fetch(connectionId).then(authInfo => {\n this.privRestAdapter.setHeaders(authInfo.headerName, authInfo.token);\n return this.privRestAdapter.request(Exports_js_1.RestRequestType.Get, this.privUri);\n });\n }\n}\nexports.SynthesisRestAdapter = SynthesisRestAdapter;","map":{"version":3,"names":["Object","defineProperty","exports","value","SynthesisRestAdapter","Exports_js_1","require","Exports_js_2","ConnectionFactoryBase_js_1","HeaderNames_js_1","constructor","config","authentication","endpoint","parameters","getProperty","PropertyId","SpeechServiceConnection_Endpoint","undefined","region","SpeechServiceConnection_Region","hostSuffix","ConnectionFactoryBase","getHostSuffix","SpeechServiceConnection_Host","privUri","options","RestConfigBase","requestOptions","privRestAdapter","RestMessageAdapter","privAuthentication","getVoicesList","connectionId","setHeaders","HeaderNames","ConnectionId","fetch","then","authInfo","headerName","token","request","RestRequestType","Get"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/SynthesisRestAdapter.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SynthesisRestAdapter = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../sdk/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\n/**\n * Implements methods for speaker recognition classes, sending requests to endpoint\n * and parsing response into expected format\n * @class SynthesisRestAdapter\n */\nclass SynthesisRestAdapter {\n constructor(config, authentication) {\n let endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Endpoint, undefined);\n if (!endpoint) {\n const region = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Region, \"westus\");\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Host, `https://${region}.tts.speech${hostSuffix}`);\n }\n this.privUri = `${endpoint}/cognitiveservices/voices/list`;\n const options = Exports_js_1.RestConfigBase.requestOptions;\n this.privRestAdapter = new Exports_js_1.RestMessageAdapter(options);\n this.privAuthentication = authentication;\n }\n /**\n * Sends list voices request to endpoint.\n * @function\n * @public\n * @param connectionId - guid for connectionId\n * @returns {Promise<IRestResponse>} rest response to status request\n */\n getVoicesList(connectionId) {\n this.privRestAdapter.setHeaders(HeaderNames_js_1.HeaderNames.ConnectionId, connectionId);\n return this.privAuthentication.fetch(connectionId).then((authInfo) => {\n this.privRestAdapter.setHeaders(authInfo.headerName, authInfo.token);\n return this.privRestAdapter.request(Exports_js_1.RestRequestType.Get, this.privUri);\n });\n }\n}\nexports.SynthesisRestAdapter = SynthesisRestAdapter;\n\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,oBAAoB,GAAG,KAAK,CAAC;AACrC,MAAMC,YAAY,GAAGC,OAAO,CAAC,8BAA8B,CAAC;AAC5D,MAAMC,YAAY,GAAGD,OAAO,CAAC,mBAAmB,CAAC;AACjD,MAAME,0BAA0B,GAAGF,OAAO,CAAC,4BAA4B,CAAC;AACxE,MAAMG,gBAAgB,GAAGH,OAAO,CAAC,kBAAkB,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,MAAMF,oBAAoB,CAAC;EACvBM,WAAWA,CAACC,MAAM,EAAEC,cAAc,EAAE;IAChC,IAAIC,QAAQ,GAAGF,MAAM,CAACG,UAAU,CAACC,WAAW,CAACR,YAAY,CAACS,UAAU,CAACC,gCAAgC,EAAEC,SAAS,CAAC;IACjH,IAAI,CAACL,QAAQ,EAAE;MACX,MAAMM,MAAM,GAAGR,MAAM,CAACG,UAAU,CAACC,WAAW,CAACR,YAAY,CAACS,UAAU,CAACI,8BAA8B,EAAE,QAAQ,CAAC;MAC9G,MAAMC,UAAU,GAAGb,0BAA0B,CAACc,qBAAqB,CAACC,aAAa,CAACJ,MAAM,CAAC;MACzFN,QAAQ,GAAGF,MAAM,CAACG,UAAU,CAACC,WAAW,CAACR,YAAY,CAACS,UAAU,CAACQ,4BAA4B,EAAE,WAAWL,MAAM,cAAcE,UAAU,EAAE,CAAC;IAC/I;IACA,IAAI,CAACI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