{"version":3,"sources":["src/sdk/AutoDetectSourceLanguageConfig.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,kBAAkB,EAElB,oBAAoB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,qBAAa,8BAA8B;IACvC,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,kBAAkB,CAAiB;IAE3C,OAAO;IAMP;;;;;;;;OAQG;WACW,aAAa,IAAI,8BAA8B;IAO7D;;;;;;;OAOG;WACW,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,8BAA8B;IAOhF;;;;;;;OAOG;WACW,yBAAyB,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,8BAA8B;IAkBxG;;;;;;OAMG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;;;;OAMG;IACH,IAAW,IAAI,CAAC,IAAI,EAAE,cAAc,EASnC;CACJ","file":"AutoDetectSourceLanguageConfig.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { AutoDetectSourceLanguagesOpenRangeOptionName } from \"../common.speech/Exports.js\";\r\nimport {Contracts} from \"./Contracts.js\";\r\nimport {\r\n    PropertyCollection,\r\n    PropertyId,\r\n    SourceLanguageConfig,\r\n} from \"./Exports.js\";\r\nimport { LanguageIdMode } from \"./LanguageIdMode.js\";\r\n\r\n/**\r\n * Language auto detect configuration.\r\n * @class AutoDetectSourceLanguageConfig\r\n * Added in version 1.13.0.\r\n */\r\nexport class AutoDetectSourceLanguageConfig {\r\n    private privProperties: PropertyCollection;\r\n    private privLanguageIdMode: LanguageIdMode;\r\n\r\n    private constructor() {\r\n        this.privProperties = new PropertyCollection();\r\n        this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"AtStart\");\r\n        this.privLanguageIdMode = LanguageIdMode.AtStart;\r\n    }\r\n\r\n    /**\r\n     * @member AutoDetectSourceLanguageConfig.fromOpenRange\r\n     * @function\r\n     * @public\r\n     * Only [[SpeechSynthesizer]] supports source language auto detection from open range,\r\n     * for [[Recognizer]], please use AutoDetectSourceLanguageConfig with specific source languages.\r\n     * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n     * @summary Creates an instance of the AutoDetectSourceLanguageConfig with open range.\r\n     */\r\n    public static fromOpenRange(): AutoDetectSourceLanguageConfig {\r\n        const config = new AutoDetectSourceLanguageConfig();\r\n        config.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, AutoDetectSourceLanguagesOpenRangeOptionName);\r\n        config.properties.setProperty(PropertyId.SpeechServiceConnection_RecoLanguage, \"en-US\");\r\n        return config;\r\n    }\r\n\r\n    /**\r\n     * @member AutoDetectSourceLanguageConfig.fromLanguages\r\n     * @function\r\n     * @public\r\n     * @param {string[]} languages Comma-separated string of languages (eg. \"en-US,fr-FR\") to populate properties of config.\r\n     * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n     * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given languages.\r\n     */\r\n    public static fromLanguages(languages: string[]): AutoDetectSourceLanguageConfig {\r\n        Contracts.throwIfArrayEmptyOrWhitespace(languages, \"languages\");\r\n        const config = new AutoDetectSourceLanguageConfig();\r\n        config.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, languages.join());\r\n        return config;\r\n    }\r\n\r\n    /**\r\n     * @member AutoDetectSourceLanguageConfig.fromSourceLanguageConfigs\r\n     * @function\r\n     * @public\r\n     * @param {SourceLanguageConfig[]} configs SourceLanguageConfigs to populate properties of config.\r\n     * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n     * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given SourceLanguageConfigs.\r\n     */\r\n    public static fromSourceLanguageConfigs(configs: SourceLanguageConfig[]): AutoDetectSourceLanguageConfig {\r\n        if (configs.length < 1) {\r\n            throw new Error(\"Expected non-empty SourceLanguageConfig array.\");\r\n        }\r\n        const autoConfig = new AutoDetectSourceLanguageConfig();\r\n        const langs: string[] = [];\r\n        configs.forEach((config: SourceLanguageConfig): void => {\r\n            langs.push(config.language);\r\n            if (config.endpointId !== undefined && config.endpointId !== \"\") {\r\n                const customProperty = config.language + PropertyId.SpeechServiceConnection_EndpointId.toString();\r\n                autoConfig.properties.setProperty(customProperty, config.endpointId);\r\n            }\r\n        });\r\n        autoConfig.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, langs.join());\r\n\r\n        return autoConfig;\r\n    }\r\n\r\n    /**\r\n     * @member AutoDetectSourceLanguageConfig.prototype.properties\r\n     * @function\r\n     * @public\r\n     * @return {PropertyCollection} Properties of the config.\r\n     * @summary Gets an auto detected language config properties\r\n     */\r\n    public get properties(): PropertyCollection {\r\n        return this.privProperties;\r\n    }\r\n\r\n    /**\r\n     * @member AutoDetectSourceLanguageConfig.prototype.mode\r\n     * @function\r\n     * @public\r\n     * @param {LanguageIdMode} mode LID mode desired.\r\n     * @summary Sets LID operation to desired mode\r\n     */\r\n    public set mode(mode: LanguageIdMode) {\r\n        if (mode === LanguageIdMode.Continuous) {\r\n            this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, \"2\");\r\n            this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"Continuous\");\r\n        } else { // LanguageIdMode.AtStart\r\n            this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, \"1\");\r\n            this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"AtStart\");\r\n        }\r\n        this.privLanguageIdMode = mode;\r\n    }\r\n}\r\n"]}