public static SpeechConfig CreateSpeechConfig()

in src/extensions/speech_extension/helpers/config_helpers.cs [17:74]


        public static SpeechConfig CreateSpeechConfig(ICommandValues values, string? key = null, string? region = null)
        {
            key = string.IsNullOrEmpty(key) ? values["service.config.key"] : key;
            region = string.IsNullOrEmpty(region) ? values["service.config.region"] : region;
            var host = values["service.config.host"];
            var endpoint = values["service.config.endpoint.uri"];
            var tokenValue = values["service.config.token.value"];

            if (values.Contains("embedded.config.embedded"))
            {
                key = "UNUSED";
                region = "UNUSED";
            }

            if (string.IsNullOrEmpty(endpoint) && string.IsNullOrEmpty(region) && string.IsNullOrEmpty(host))
            {
                values.AddThrowError("ERROR:", $"Creating SpeechConfig; requires one of: region, endpoint, or host.");
            }
            else if (!string.IsNullOrEmpty(region) && string.IsNullOrEmpty(tokenValue) && string.IsNullOrEmpty(key))
            {
                values.AddThrowError("ERROR:", $"Creating SpeechConfig; use of region requires one of: key or token.");
            }

            SpeechConfig config;
            if (!string.IsNullOrEmpty(endpoint))
            {
                config = string.IsNullOrEmpty(key)
                    ? SpeechConfig.FromEndpoint(new Uri(endpoint))
                    : SpeechConfig.FromEndpoint(new Uri(endpoint), key);
            }
            else if (!string.IsNullOrEmpty(host))
            {
                config = string.IsNullOrEmpty(key)
                    ? SpeechConfig.FromHost(new Uri(host))
                    : SpeechConfig.FromHost(new Uri(host), key);
            }
            else // if (!string.IsNullOrEmpty(region))
            {
                config = string.IsNullOrEmpty(tokenValue)
                    ? SpeechConfig.FromSubscription(key, region)
                    : SpeechConfig.FromAuthorizationToken(tokenValue, region);
            }

            if (!string.IsNullOrEmpty(tokenValue))
            {
                config.AuthorizationToken = tokenValue;
            }

            SetupLogFile(config, values);

            var stringProperty = values.GetOrEmpty("config.string.property");
            if (!string.IsNullOrEmpty(stringProperty)) ConfigHelpers.SetStringProperty(config, stringProperty);

            var stringProperties = values.GetOrEmpty("config.string.properties");
            if (!string.IsNullOrEmpty(stringProperties)) ConfigHelpers.SetStringProperties(config, stringProperties);

            return config;
        }