in src/extensions/speech_extension/commands/synthesize_command.cs [224:277]
private SpeechConfig CreateSpeechConfig()
{
var key = _values["service.config.key"];
var host = _values["service.config.host"];
var region = _values["service.config.region"];
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 = null;
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;
}
var format = _values["audio.output.format"];
if (!string.IsNullOrEmpty(format)) config.SetSpeechSynthesisOutputFormat(AudioOutputHelpers.OutputFormatFrom(format));
SetSpeechConfigProperties(config);
return config;
}