@hahnpro/ms-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 4.53 kB
Source Map (JSON)
{"version":3,"sources":["src/common.speech/SpeakerRecognitionConnectionFactory.ts"],"names":[],"mappings":"AASA,OAAO,EACH,WAAW,EAEd,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACH,qBAAqB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,QAAQ,EACR,gBAAgB,EAEnB,MAAM,cAAc,CAAC;AAGtB,cAAM,uCAAwC,SAAQ,qBAAqB;IAEhE,MAAM,CACT,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA+BhD,OAAO,CAAC,cAAc;CAYzB;AAED,qBAAa,mCAAoC,SAAQ,uCAAuC;IACrF,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAG3G;AAED,qBAAa,6BAA8B,SAAQ,uCAAuC;IAC/E,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAG3G","file":"SpeakerRecognitionConnectionFactory.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/* eslint-disable max-classes-per-file */\n\nimport {\n ProxyInfo,\n WebsocketConnection,\n} from \"../common.browser/Exports.js\";\nimport {\n IConnection,\n IStringDictionary\n} from \"../common/Exports.js\";\nimport {\n PropertyId\n} from \"../sdk/Exports.js\";\nimport {\n ConnectionFactoryBase\n} from \"./ConnectionFactoryBase.js\";\nimport {\n AuthInfo,\n RecognizerConfig,\n WebsocketMessageFormatter,\n} from \"./Exports.js\";\nimport { HeaderNames } from \"./HeaderNames.js\";\n\nclass SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {\n\n public create(\n config: RecognizerConfig,\n authInfo: AuthInfo,\n endpointPath: string,\n connectionId?: string): Promise<IConnection> {\n\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);\n if (!endpoint) {\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region);\n const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `wss://${region}.spr-frontend.speech${hostSuffix}`);\n const scenario: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_SpeakerIdMode, \"TextIndependentIdentification\");\n endpoint = `${host}/speaker/ws/${this.scenarioToPath(scenario)}/${endpointPath}`;\n }\n\n const queryParams: IStringDictionary<string> = {\n format: \"simple\",\n language: config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\n };\n\n this.setCommonUrlParams(config, queryParams, endpoint);\n\n const headers: IStringDictionary<string> = {};\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\n headers[authInfo.headerName] = authInfo.token;\n }\n headers[HeaderNames.ConnectionId] = connectionId;\n headers[HeaderNames.SpIDAuthKey] = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Key);\n\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\n\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\n return Promise.resolve(new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId));\n }\n\n private scenarioToPath(mode: string): string {\n switch (mode) {\n case \"TextIndependentVerification\":\n case \"2\":\n return \"verification/text-independent\";\n case \"TextDependentVerification\":\n case \"1\":\n return \"verification/text-dependent\";\n default:\n return \"identification/text-independent\";\n }\n }\n}\n\nexport class SpeakerRecognitionConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\n public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): Promise<IConnection> {\n return super.create(config, authInfo, \"recognition\", connectionId);\n }\n}\n\nexport class VoiceProfileConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\n public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): Promise<IConnection> {\n return super.create(config, authInfo, \"profile\", connectionId);\n }\n}\n\n"]}