UNPKG

hip1-microsoft-cognitiveservices-speech-sdk

Version:
1 lines 4.17 kB
{"version":3,"sources":["src/common.speech/ConnectionFactoryBase.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG9E,8BAAsB,qBAAsB,YAAW,kBAAkB;WAEvD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;aAYnC,MAAM,CAClB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IAEvC,SAAS,CAAC,kBAAkB,CACxB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,EACtC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAyB3B,SAAS,CAAC,eAAe,CACrB,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,EACtC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAW9B","file":"ConnectionFactoryBase.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport {\n ServicePropertiesPropertyName,\n} from \"../common.speech/Exports.js\";\nimport { IConnection, IStringDictionary } from \"../common/Exports.js\";\nimport { PropertyId } from \"../sdk/Exports.js\";\nimport { AuthInfo, IConnectionFactory, RecognizerConfig } from \"./Exports.js\";\nimport { QueryParameterNames } from \"./QueryParameterNames.js\";\n\nexport abstract class ConnectionFactoryBase implements IConnectionFactory {\n\n public static getHostSuffix(region: string): string {\n if (!!region) {\n if (region.toLowerCase().startsWith(\"china\")) {\n return \".azure.cn\";\n }\n if (region.toLowerCase().startsWith(\"usgov\")) {\n return \".azure.us\";\n }\n }\n return \".microsoft.com\";\n }\n\n public abstract create(\n config: RecognizerConfig,\n authInfo: AuthInfo,\n connectionId?: string): IConnection;\n\n protected setCommonUrlParams(\n config: RecognizerConfig,\n queryParams: IStringDictionary<string>,\n endpoint: string): void {\n\n const propertyIdToParameterMap: Map<number, string> = new Map([\n [PropertyId.Speech_SegmentationSilenceTimeoutMs, QueryParameterNames.SegmentationSilenceTimeoutMs],\n [PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames.EnableAudioLogging],\n [PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames.EndSilenceTimeoutMs],\n [PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames.InitialSilenceTimeoutMs],\n [PropertyId.SpeechServiceResponse_PostProcessingOption, QueryParameterNames.Postprocessing],\n [PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames.Profanity],\n [PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, QueryParameterNames.EnableWordLevelTimestamps],\n [PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames.StableIntermediateThreshold],\n ]);\n\n propertyIdToParameterMap.forEach((parameterName: string, propertyId: PropertyId): void => {\n this.setUrlParameter(propertyId, parameterName, config, queryParams, endpoint);\n });\n\n\n const serviceProperties: IStringDictionary<string> = JSON.parse(config.parameters.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\n\n Object.keys(serviceProperties).forEach((value: string): void => {\n queryParams[value] = serviceProperties[value];\n });\n }\n\n protected setUrlParameter(\n propId: PropertyId,\n parameterName: string,\n config: RecognizerConfig,\n queryParams: IStringDictionary<string>,\n endpoint: string): void {\n\n const value: string = config.parameters.getProperty(propId, undefined);\n\n // FIXME: The .search() check will incorrectly match parameter name anywhere in the string\n // including e.g. the path portion, or even as a substring of other query parameters\n if (value && (!endpoint || endpoint.search(parameterName) === -1)) {\n queryParams[parameterName] = value.toLocaleLowerCase();\n }\n }\n\n}\n"]}