{"version":3,"sources":["src/common.speech/TranscriberConnectionFactory.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,WAAW,EACX,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACH,qBAAqB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,QAAQ,EAER,gBAAgB,EAEnB,MAAM,cAAc,CAAC;AAMtB,qBAAa,4BAA6B,SAAQ,qBAAqB;IAEnE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA4C;IAE3E,MAAM,CACT,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA2BzC,cAAc,CAAC,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;CAqBrH","file":"TranscriberConnectionFactory.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport {\n    ProxyInfo,\n    WebsocketConnection,\n} from \"../common.browser/Exports.js\";\nimport {\n    IConnection,\n    IStringDictionary\n} from \"../common/Exports.js\";\nimport {\n    OutputFormat,\n    PropertyId\n} from \"../sdk/Exports.js\";\nimport {\n    ConnectionFactoryBase\n} from \"./ConnectionFactoryBase.js\";\nimport {\n    AuthInfo,\n    OutputFormatPropertyName,\n    RecognizerConfig,\n    WebsocketMessageFormatter\n} from \"./Exports.js\";\nimport { HeaderNames } from \"./HeaderNames.js\";\nimport {\n    QueryParameterNames\n} from \"./QueryParameterNames.js\";\n\nexport class TranscriberConnectionFactory extends ConnectionFactoryBase {\n\n    private readonly multiaudioRelativeUri: string = \"/speech/recognition/multiaudio\";\n\n    public create(\n        config: RecognizerConfig,\n        authInfo: AuthInfo,\n        connectionId?: string): Promise<IConnection> {\n\n        let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\n        const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, \"centralus\");\n        const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\n        const hostDefault: string = \"wss://transcribe.\" + region + \".cts.speech\" + hostSuffix + this.multiaudioRelativeUri;\n        const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, hostDefault);\n\n        const queryParams: IStringDictionary<string> = {};\n        this.setQueryParams(queryParams, config, endpoint);\n\n        if (!endpoint) {\n            endpoint = host;\n        }\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\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    public setQueryParams(queryParams: IStringDictionary<string>, config: RecognizerConfig, endpointUrl: string): void {\n\n        const endpointId: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_EndpointId, undefined);\n        const language: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, undefined);\n\n        if (endpointId && !(QueryParameterNames.CustomSpeechDeploymentId in queryParams)) {\n            queryParams[QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\n        }\n\n        if (language && !(QueryParameterNames.Language in queryParams)) {\n            queryParams[QueryParameterNames.Language] = language;\n        }\n\n        const wordLevelTimings: boolean = config.parameters.getProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, \"false\").toLowerCase() === \"true\";\n        const detailed: boolean = config.parameters.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]) !== OutputFormat[OutputFormat.Simple];\n        if (wordLevelTimings || detailed) {\n            queryParams[QueryParameterNames.Format] = OutputFormat[OutputFormat.Detailed].toLowerCase();\n        }\n\n        this.setCommonUrlParams(config, queryParams, endpointUrl);\n    }\n}\n"]}