{"version":3,"sources":["src/common.speech/SpeechSynthesisConnectionFactory.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,WAAW,EAEd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACH,QAAQ,EACR,iBAAiB,EAEpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E,qBAAa,gCAAiC,YAAW,2BAA2B;IAEhF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6C;IAEnE,MAAM,WACD,iBAAiB,YACf,QAAQ,iBACH,MAAM,KAAG,WAAW,CA4BtC;CACJ","file":"SpeechSynthesisConnectionFactory.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n    ProxyInfo,\r\n    WebsocketConnection, WebsocketMessageAdapter,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n    IConnection,\r\n    IStringDictionary\r\n} from \"../common/Exports\";\r\nimport { PropertyId } from \"../sdk/Exports\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase\";\r\nimport {\r\n    AuthInfo,\r\n    SynthesizerConfig,\r\n    WebsocketMessageFormatter\r\n} from \"./Exports\";\r\nimport { HeaderNames } from \"./HeaderNames\";\r\nimport { ISynthesisConnectionFactory } from \"./ISynthesisConnectionFactory\";\r\nimport {\r\n    QueryParameterNames\r\n} from \"./QueryParameterNames\";\r\n\r\nexport class SpeechSynthesisConnectionFactory implements ISynthesisConnectionFactory {\r\n\r\n    private readonly synthesisUri: string = \"/cognitiveservices/websocket/v1\";\r\n\r\n    public create = (\r\n        config: SynthesizerConfig,\r\n        authInfo: AuthInfo,\r\n        connectionId?: string): IConnection => {\r\n\r\n        let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n        const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, undefined);\r\n        const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n        const endpointId = config.parameters.getProperty(PropertyId.SpeechServiceConnection_EndpointId, undefined);\r\n        const hostPrefix = (endpointId === undefined) ? \"tts\" : \"voice\";\r\n        const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".\" + hostPrefix + \".speech\" + hostSuffix);\r\n\r\n        const queryParams: IStringDictionary<string> = {};\r\n\r\n        if (!endpoint) {\r\n            endpoint = host + this.synthesisUri;\r\n        }\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        if (endpointId !== undefined) {\r\n            headers[QueryParameterNames.CustomVoiceDeploymentId] = endpointId;\r\n        }\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 new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromParameters(config.parameters), enableCompression, connectionId);\r\n    }\r\n}\r\n"]}