{"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ConversationTranscriberConnectionFactory = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../sdk/Exports.js\");\nconst Exports_js_3 = require(\"../common.speech/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\nconst QueryParameterNames_js_1 = require(\"./QueryParameterNames.js\");\nclass ConversationTranscriberConnectionFactory extends ConnectionFactoryBase_js_1.ConnectionFactoryBase {\n constructor() {\n super(...arguments);\n this.universalUri = \"/speech/universal/v2\";\n }\n create(config, authInfo, connectionId) {\n let endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Endpoint, undefined);\n const region = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Region, undefined);\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n const host = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".stt.speech\" + hostSuffix);\n const queryParams = {};\n const endpointId = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_EndpointId, undefined);\n const language = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_RecoLanguage, undefined);\n if (endpointId) {\n if (!endpoint || endpoint.search(QueryParameterNames_js_1.QueryParameterNames.CustomSpeechDeploymentId) === -1) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\n }\n } else if (language) {\n if (!endpoint || endpoint.search(QueryParameterNames_js_1.QueryParameterNames.Language) === -1) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Language] = language;\n }\n }\n if (config.autoDetectSourceLanguages !== undefined) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.EnableLanguageId] = \"true\";\n }\n this.setV2UrlParams(config, queryParams, endpoint);\n if (!endpoint) {\n endpoint = `${host}${this.universalUri}`;\n }\n const headers = {};\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\n headers[authInfo.headerName] = authInfo.token;\n }\n headers[HeaderNames_js_1.HeaderNames.ConnectionId] = connectionId;\n const enableCompression = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\n const webSocketConnection = new Exports_js_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_js_4.WebsocketMessageFormatter(), Exports_js_1.ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\n // Set the value of SpeechServiceConnection_Url to webSocketConnection.uri (and not to `endpoint`), since this value is the final\n // URI that was used to make the connection (including query parameters).\n const uri = webSocketConnection.uri;\n config.parameters.setProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Url, uri);\n return webSocketConnection;\n }\n setV2UrlParams(config, queryParams, endpoint) {\n const propertyIdToParameterMap = new Map([[Exports_js_2.PropertyId.Speech_SegmentationSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.SegmentationSilenceTimeoutMs], [Exports_js_2.PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames_js_1.QueryParameterNames.EnableAudioLogging], [Exports_js_2.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.EndSilenceTimeoutMs], [Exports_js_2.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.InitialSilenceTimeoutMs], [Exports_js_2.PropertyId.SpeechServiceResponse_PostProcessingOption, QueryParameterNames_js_1.QueryParameterNames.Postprocessing], [Exports_js_2.PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames_js_1.QueryParameterNames.Profanity], [Exports_js_2.PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames_js_1.QueryParameterNames.StableIntermediateThreshold]]);\n propertyIdToParameterMap.forEach((parameterName, propertyId) => {\n this.setUrlParameter(propertyId, parameterName, config, queryParams, endpoint);\n });\n const serviceProperties = JSON.parse(config.parameters.getProperty(Exports_js_3.ServicePropertiesPropertyName, \"{}\"));\n Object.keys(serviceProperties).forEach(value => {\n queryParams[value] = serviceProperties[value];\n });\n }\n}\nexports.ConversationTranscriberConnectionFactory = ConversationTranscriberConnectionFactory;","map":{"version":3,"names":["Object","defineProperty","exports","value","ConversationTranscriberConnectionFactory","Exports_js_1","require","Exports_js_2","Exports_js_3","ConnectionFactoryBase_js_1","Exports_js_4","HeaderNames_js_1","QueryParameterNames_js_1","ConnectionFactoryBase","constructor","arguments","universalUri","create","config","authInfo","connectionId","endpoint","parameters","getProperty","PropertyId","SpeechServiceConnection_Endpoint","undefined","region","SpeechServiceConnection_Region","hostSuffix","getHostSuffix","host","SpeechServiceConnection_Host","queryParams","endpointId","SpeechServiceConnection_EndpointId","language","SpeechServiceConnection_RecoLanguage","search","QueryParameterNames","CustomSpeechDeploymentId","Language","autoDetectSourceLanguages","EnableLanguageId","setV2UrlParams","headers","token","headerName","HeaderNames","ConnectionId","enableCompression","webSocketConnection","WebsocketConnection","WebsocketMessageFormatter","ProxyInfo","fromRecognizerConfig","uri","setProperty","SpeechServiceConnection_Url","propertyIdToParameterMap","Map","Speech_SegmentationSilenceTimeoutMs","SegmentationSilenceTimeoutMs","SpeechServiceConnection_EnableAudioLogging","EnableAudioLogging","SpeechServiceConnection_EndSilenceTimeoutMs","EndSilenceTimeoutMs","SpeechServiceConnection_InitialSilenceTimeoutMs","InitialSilenceTimeoutMs","SpeechServiceResponse_PostProcessingOption","Postprocessing","SpeechServiceResponse_ProfanityOption","Profanity","SpeechServiceResponse_StablePartialResultThreshold","StableIntermediateThreshold","forEach","parameterName","propertyId","setUrlParameter","serviceProperties","JSON","parse","ServicePropertiesPropertyName","keys"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ConversationTranscriberConnectionFactory.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ConversationTranscriberConnectionFactory = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../sdk/Exports.js\");\nconst Exports_js_3 = require(\"../common.speech/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\nconst QueryParameterNames_js_1 = require(\"./QueryParameterNames.js\");\nclass ConversationTranscriberConnectionFactory extends ConnectionFactoryBase_js_1.ConnectionFactoryBase {\n constructor() {\n super(...arguments);\n this.universalUri = \"/speech/universal/v2\";\n }\n create(config, authInfo, connectionId) {\n let endpoint = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Endpoint, undefined);\n const region = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Region, undefined);\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n const host = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".stt.speech\" + hostSuffix);\n const queryParams = {};\n const endpointId = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_EndpointId, undefined);\n const language = config.parameters.getProperty(Exports_js_2.PropertyId.SpeechServiceConnection_RecoLanguage, undefined);\n if (endpointId) {\n if (!endpoint || endpoint.search(QueryParameterNames_js_1.QueryParameterNames.CustomSpeechDeploymentId) === -1) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\n }\n }\n else if (language) {\n if (!endpoint || endpoint.search(QueryParameterNames_js_1.QueryParameterNames.Language) === -1) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Language] = language;\n }\n }\n if (config.autoDetectSourceLanguages !== undefined) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.EnableLanguageId] = \"true\";\n }\n this.setV2UrlParams(config, queryParams, endpoint);\n if (!endpoint) {\n endpoint = `${host}${this.universalUri}`;\n }\n const headers = {};\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\n headers[authInfo.headerName] = authInfo.token;\n }\n headers[HeaderNames_js_1.HeaderNames.ConnectionId] = connectionId;\n const enableCompression = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\n const webSocketConnection = new Exports_js_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_js_4.WebsocketMessageFormatter(), Exports_js_1.ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\n // Set the value of SpeechServiceConnection_Url to webSocketConnection.uri (and not to `endpoint`), since this value is the final\n // URI that was used to make the connection (including query parameters).\n const uri = webSocketConnection.uri;\n config.parameters.setProperty(Exports_js_2.PropertyId.SpeechServiceConnection_Url, uri);\n return webSocketConnection;\n }\n setV2UrlParams(config, queryParams, endpoint) {\n const propertyIdToParameterMap = new Map([\n [Exports_js_2.PropertyId.Speech_SegmentationSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.SegmentationSilenceTimeoutMs],\n [Exports_js_2.PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames_js_1.QueryParameterNames.EnableAudioLogging],\n [Exports_js_2.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.EndSilenceTimeoutMs],\n [Exports_js_2.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames_js_1.QueryParameterNames.InitialSilenceTimeoutMs],\n [Exports_js_2.PropertyId.SpeechServiceResponse_PostProcessingOption, QueryParameterNames_js_1.QueryParameterNames.Postprocessing],\n [Exports_js_2.PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames_js_1.QueryParameterNames.Profanity],\n [Exports_js_2.PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames_js_1.QueryParameterNames.StableIntermediateThreshold],\n ]);\n propertyIdToParameterMap.forEach((parameterName, propertyId) => {\n this.setUrlParameter(propertyId, parameterName, config, queryParams, endpoint);\n });\n const serviceProperties = JSON.parse(config.parameters.getProperty(Exports_js_3.ServicePropertiesPropertyName, \"{}\"));\n Object.keys(serviceProperties).forEach((value) => {\n queryParams[value] = serviceProperties[value];\n });\n }\n}\nexports.ConversationTranscriberConnectionFactory = ConversationTranscriberConnectionFactory;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,wCAAwC,GAAG,KAAK,CAAC;AACzD,MAAMC,YAAY,GAAGC,OAAO,CAAC,8BAA8B,CAAC;AAC5D,MAAMC,YAAY,GAAGD,OAAO,CAAC,mBAAmB,CAAC;AACjD,MAAME,YAAY,GAAGF,OAAO,CAAC,6BAA6B,CAAC;AAC3D,MAAMG,0BAA0B,GAAGH,OAAO,CAAC,4BAA4B,CAAC;AACxE,MAAMI,YAAY,GAAGJ,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAMK,gBAAgB,GAAGL,OAAO,CAAC,kBAAkB,CAAC;AACpD,MAAMM,wBAAwB,GAAGN,OAAO,CAAC,0BAA0B,CAAC;AACpE,MAAMF,wCAAwC,SAASK,0BAA0B,CAACI,qBAAqB,CAAC;EACpGC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC,GAAGC,SAAS,CAAC;IACnB,IAAI,CAACC,YAAY,GAAG,sBAAsB;EAC9C;EACAC,MAAMA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE;IACnC,IAAIC,QAAQ,GAAGH,MAAM,CAACI,UAAU,CAACC,WAAW,CAAChB,YAAY,CAACiB,UAAU,CAACC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