{"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.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n    ProxyInfo,\r\n    WebsocketConnection,\r\n} from \"../common.browser/Exports.js\";\r\nimport {\r\n    IConnection,\r\n    IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n    PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n    ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n    AuthInfo,\r\n    RecognizerConfig,\r\n    WebsocketMessageFormatter,\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\n\r\nclass SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {\r\n\r\n    public create(\r\n        config: RecognizerConfig,\r\n        authInfo: AuthInfo,\r\n        endpointPath: string,\r\n        connectionId?: string): Promise<IConnection> {\r\n\r\n        let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);\r\n        if (!endpoint) {\r\n            const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n            const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n            const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `wss://${region}.spr-frontend.speech${hostSuffix}`);\r\n            const scenario: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_SpeakerIdMode, \"TextIndependentIdentification\");\r\n            endpoint = `${host}/speaker/ws/${this.scenarioToPath(scenario)}/${endpointPath}`;\r\n        }\r\n\r\n        const queryParams: IStringDictionary<string> = {\r\n            format: \"simple\",\r\n            language: config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\r\n        };\r\n\r\n        this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n        const headers: IStringDictionary<string> = {};\r\n        if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n            headers[authInfo.headerName] = authInfo.token;\r\n        }\r\n        headers[HeaderNames.ConnectionId] = connectionId;\r\n        headers[HeaderNames.SpIDAuthKey] = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Key);\r\n\r\n        config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n        const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n        return Promise.resolve(new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId));\r\n    }\r\n\r\n    private scenarioToPath(mode: string): string {\r\n        switch (mode) {\r\n            case \"TextIndependentVerification\":\r\n            case \"2\":\r\n                return \"verification/text-independent\";\r\n            case \"TextDependentVerification\":\r\n            case \"1\":\r\n                return \"verification/text-dependent\";\r\n            default:\r\n                return \"identification/text-independent\";\r\n        }\r\n    }\r\n}\r\n\r\nexport class SpeakerRecognitionConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\r\n    public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): Promise<IConnection> {\r\n        return super.create(config, authInfo, \"recognition\", connectionId);\r\n    }\r\n}\r\n\r\nexport class VoiceProfileConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\r\n    public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): Promise<IConnection> {\r\n        return super.create(config, authInfo, \"profile\", connectionId);\r\n    }\r\n}\r\n\r\n"]}