diff --git a/clients/csharp-wpf/VoiceAssistantClient/MainWindow.xaml.cs b/clients/csharp-wpf/VoiceAssistantClient/MainWindow.xaml.cs
index fd5a93c9..d5c42bdf 100644
--- a/clients/csharp-wpf/VoiceAssistantClient/MainWindow.xaml.cs
+++ b/clients/csharp-wpf/VoiceAssistantClient/MainWindow.xaml.cs
@@ -139,7 +139,7 @@ protected override void OnContentRendered(EventArgs e)
// URL, a URL override. If the client doesn't meet these requirements (e.g. on first
// run), pop up the settings dialog to prompt for it.
var hasSubscriptionKey = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.SubscriptionKey);
- var hasSubscriptionRegion = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.SubscriptionKeyRegion);
+ var hasSubscriptionRegion = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.SubscriptionRegion);
var hasUrlOverride = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.UrlOverride);
if (!hasSubscriptionKey || (!hasSubscriptionRegion && !hasUrlOverride))
@@ -204,89 +204,113 @@ private void InitSpeechConnector()
{
DialogServiceConfig config = null;
- var hasSubscription = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.SubscriptionKey);
- var hasRegion = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.SubscriptionKeyRegion);
- var hasBotId = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.BotId);
- var hasUrlOverride = !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.UrlOverride);
+ var profile = this.settings.RuntimeSettings.Profile;
+ var hasSubscription = !string.IsNullOrWhiteSpace(profile.SubscriptionKey);
+ var hasAuthToken = !string.IsNullOrWhiteSpace(profile.AuthorizationToken);
+ var hasRegion = !string.IsNullOrWhiteSpace(profile.SubscriptionRegion);
+ var hasBotId = !string.IsNullOrWhiteSpace(profile.BotId);
+ var hasUrlOverride = !string.IsNullOrWhiteSpace(profile.UrlOverride);
- if (hasSubscription && (hasRegion || hasUrlOverride))
+ if ((hasSubscription || hasAuthToken) && (hasRegion || hasUrlOverride))
{
- if (!string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.CustomCommandsAppId))
+ if (!string.IsNullOrWhiteSpace(profile.CustomCommandsAppId))
{
// NOTE: Custom commands is a preview Azure Service.
// Set the custom commands configuration object based on three items:
// - The Custom commands application ID
- // - Cognitive services speech subscription key.
+ // - Cognitive services speech subscription key or auth token.
// - The Azure region of the subscription key(e.g. "westus").
- config = CustomCommandsConfig.FromSubscription(this.settings.RuntimeSettings.Profile.CustomCommandsAppId, this.settings.RuntimeSettings.Profile.SubscriptionKey, this.settings.RuntimeSettings.Profile.SubscriptionKeyRegion);
- }
- else if (hasBotId)
- {
- config = BotFrameworkConfig.FromSubscription(this.settings.RuntimeSettings.Profile.SubscriptionKey, this.settings.RuntimeSettings.Profile.SubscriptionKeyRegion, this.settings.RuntimeSettings.Profile.BotId);
+ config =
+ hasSubscription ? CustomCommandsConfig.FromSubscription(
+ profile.CustomCommandsAppId,
+ profile.SubscriptionKey,
+ profile.SubscriptionRegion)
+ : hasAuthToken ? CustomCommandsConfig.FromAuthorizationToken(
+ profile.CustomCommandsAppId,
+ profile.AuthorizationToken,
+ profile.SubscriptionRegion)
+ : throw new ArgumentException();
}
else
{
// Set the bot framework configuration object based on two items:
- // - Cognitive services speech subscription key. It is needed for billing and is tied to the bot registration.
- // - The Azure region of the subscription key(e.g. "westus").
- config = BotFrameworkConfig.FromSubscription(this.settings.RuntimeSettings.Profile.SubscriptionKey, this.settings.RuntimeSettings.Profile.SubscriptionKeyRegion);
+ // - Cognitive services speech subscription key or auth token. This is needed for billing and is
+ // tied to the bot registration.
+ // - The Azure region of the subscription key (e.g. "westus").
+
+ config =
+ (hasSubscription && hasBotId) ? BotFrameworkConfig.FromSubscription(
+ profile.SubscriptionKey,
+ profile.SubscriptionRegion,
+ profile.BotId)
+ : (hasSubscription && !hasBotId) ? BotFrameworkConfig.FromSubscription(
+ profile.SubscriptionKey,
+ profile.SubscriptionRegion)
+ : (hasAuthToken && hasBotId) ? BotFrameworkConfig.FromAuthorizationToken(
+ profile.AuthorizationToken,
+ profile.SubscriptionRegion,
+ profile.BotId)
+ : (hasAuthToken && !hasBotId) ? BotFrameworkConfig.FromAuthorizationToken(
+ profile.AuthorizationToken,
+ profile.SubscriptionRegion)
+ : throw new ArgumentException();
}
}
- if (!string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.ConnectionLanguage))
+ if (!string.IsNullOrWhiteSpace(profile.ConnectionLanguage))
{
// Set the speech recognition language. If not set, the default is "en-us".
- config.Language = this.settings.RuntimeSettings.Profile.ConnectionLanguage;
+ config.Language = profile.ConnectionLanguage;
}
- if (this.settings.RuntimeSettings.Profile.CustomSpeechEnabled)
+ if (profile.CustomSpeechEnabled)
{
// Set your custom speech end-point id here, as given to you by the speech portal https://speech.microsoft.com/portal.
// Otherwise the standard speech end-point will be used.
- config.SetServiceProperty("cid", this.settings.RuntimeSettings.Profile.CustomSpeechEndpointId, ServicePropertyChannel.UriQueryParameter);
+ config.SetServiceProperty("cid", profile.CustomSpeechEndpointId, ServicePropertyChannel.UriQueryParameter);
// Custom Speech does not support cloud Keyword Verification at the moment. If this is not done, there will be an error
// from the service and connection will close. Remove line below when supported.
config.SetProperty("KeywordConfig_EnableKeywordVerification", "false");
}
- if (this.settings.RuntimeSettings.Profile.VoiceDeploymentEnabled)
+ if (profile.VoiceDeploymentEnabled)
{
// Set one or more IDs associated with the custom TTS voice your bot will use
// The format of the string is one or more GUIDs separated by comma (no spaces). You get these GUIDs from
// your custom TTS on the speech portal https://speech.microsoft.com/portal.
- config.SetProperty(PropertyId.Conversation_Custom_Voice_Deployment_Ids, this.settings.RuntimeSettings.Profile.VoiceDeploymentIds);
+ config.SetProperty(PropertyId.Conversation_Custom_Voice_Deployment_Ids, profile.VoiceDeploymentIds);
}
- if (!string.IsNullOrEmpty(this.settings.RuntimeSettings.Profile.FromId))
+ if (!string.IsNullOrEmpty(profile.FromId))
{
// Set the from.id in the Bot-Framework Activity sent by this tool.
// from.id field identifies who generated the activity, and may be required by some bots.
// See https://github.com/microsoft/botframework-sdk/blob/master/specs/botframework-activity/botframework-activity.md
// for Bot Framework Activity schema and from.id.
- config.SetProperty(PropertyId.Conversation_From_Id, this.settings.RuntimeSettings.Profile.FromId);
+ config.SetProperty(PropertyId.Conversation_From_Id, profile.FromId);
}
- if (!string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.LogFilePath))
+ if (!string.IsNullOrWhiteSpace(profile.LogFilePath))
{
// Speech SDK has verbose logging to local file, which may be useful when reporting issues.
// Supply the path to a text file on disk here. By default no logging happens.
- config.SetProperty(PropertyId.Speech_LogFilename, this.settings.RuntimeSettings.Profile.LogFilePath);
+ config.SetProperty(PropertyId.Speech_LogFilename, profile.LogFilePath);
}
if (hasUrlOverride)
{
// For prototyping new Direct Line Speech channel service feature, a custom service URL may be
// provided by Microsoft and entered in this tool.
- config.SetProperty("SPEECH-Endpoint", this.settings.RuntimeSettings.Profile.UrlOverride);
+ config.SetProperty("SPEECH-Endpoint", profile.UrlOverride);
}
- if (!string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.ProxyHostName) &&
- !string.IsNullOrWhiteSpace(this.settings.RuntimeSettings.Profile.ProxyPortNumber) &&
- int.TryParse(this.settings.RuntimeSettings.Profile.ProxyPortNumber, out var proxyPortNumber))
+ if (!string.IsNullOrWhiteSpace(profile.ProxyHostName) &&
+ !string.IsNullOrWhiteSpace(profile.ProxyPortNumber) &&
+ int.TryParse(profile.ProxyPortNumber, out var proxyPortNumber))
{
// To funnel network traffic via a proxy, set the host name and port number here
- config.SetProxy(this.settings.RuntimeSettings.Profile.ProxyHostName, proxyPortNumber, string.Empty, string.Empty);
+ config.SetProxy(profile.ProxyHostName, proxyPortNumber, string.Empty, string.Empty);
}
// If a the DialogServiceConnector object already exists, destroy it first
@@ -317,15 +341,15 @@ private void InitSpeechConnector()
// Open a connection to Direct Line Speech channel
this.connector.ConnectAsync();
- if (this.settings.RuntimeSettings.Profile.CustomSpeechEnabled)
+ if (profile.CustomSpeechEnabled)
{
- this.customSpeechConfig = new CustomSpeechConfiguration(this.settings.RuntimeSettings.Profile.CustomSpeechEndpointId);
+ this.customSpeechConfig = new CustomSpeechConfiguration(profile.CustomSpeechEndpointId);
}
- if (this.settings.RuntimeSettings.Profile.WakeWordEnabled)
+ if (profile.WakeWordEnabled)
{
// Configure wake word (also known as "keyword")
- this.activeWakeWordConfig = new WakeWordConfiguration(this.settings.RuntimeSettings.Profile.WakeWordPath);
+ this.activeWakeWordConfig = new WakeWordConfiguration(profile.WakeWordPath);
this.connector.StartKeywordRecognitionAsync(this.activeWakeWordConfig.WakeWordModel);
}
}
diff --git a/clients/csharp-wpf/VoiceAssistantClient/Settings/ConnectionProfile.cs b/clients/csharp-wpf/VoiceAssistantClient/Settings/ConnectionProfile.cs
index e9119cc3..370b6560 100644
--- a/clients/csharp-wpf/VoiceAssistantClient/Settings/ConnectionProfile.cs
+++ b/clients/csharp-wpf/VoiceAssistantClient/Settings/ConnectionProfile.cs
@@ -5,9 +5,11 @@ namespace VoiceAssistantClient.Settings
{
public class ConnectionProfile
{
- public string SubscriptionKey { get; set; }
+ public string SubscriptionKey { get; set; }
+
+ public string AuthorizationToken { get; set; }
- public string SubscriptionKeyRegion { get; set; }
+ public string SubscriptionRegion { get; set; }
public string CustomCommandsAppId { get; set; }
diff --git a/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml b/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml
index eae95261..62671600 100644
--- a/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml
+++ b/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml
@@ -56,23 +56,26 @@
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml.cs b/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml.cs
index 2e18e09e..828504d4 100644
--- a/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml.cs
+++ b/clients/csharp-wpf/VoiceAssistantClient/SettingsDialog.xaml.cs
@@ -63,7 +63,8 @@ protected override void OnActivated(EventArgs e)
this.ConnectionProfileComboBox.ItemsSource = this.settings.ConnectionProfileNameHistory;
this.ConnectionProfileComboBox.Text = this.ConnectionProfileName;
this.SubscriptionKeyTextBox.Text = this.settings.Profile.SubscriptionKey;
- this.SubscriptionRegionTextBox.Text = this.settings.Profile.SubscriptionKeyRegion;
+ this.AuthorizationTokenTextBox.Text = this.settings.Profile.AuthorizationToken;
+ this.SubscriptionRegionTextBox.Text = this.settings.Profile.SubscriptionRegion;
this.CustomCommandsAppIdTextBox.Text = this.settings.Profile.CustomCommandsAppId;
this.BotIdTextBox.Text = this.settings.Profile.BotId;
this.LanguageTextBox.Text = this.settings.Profile.ConnectionLanguage;
@@ -102,7 +103,8 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
if (this.connectionProfile.ContainsKey(this.ConnectionProfileComboBox.Text))
{
this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKey = this.SubscriptionKeyTextBox.Text;
- this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKeyRegion = this.SubscriptionRegionTextBox.Text;
+ this.connectionProfile[this.ConnectionProfileComboBox.Text].AuthorizationToken = this.AuthorizationTokenTextBox.Text;
+ this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionRegion = this.SubscriptionRegionTextBox.Text;
this.connectionProfile[this.ConnectionProfileComboBox.Text].CustomCommandsAppId = this.CustomCommandsAppIdTextBox.Text;
this.connectionProfile[this.ConnectionProfileComboBox.Text].BotId = this.BotIdTextBox.Text;
this.connectionProfile[this.ConnectionProfileComboBox.Text].ConnectionLanguage = this.LanguageTextBox.Text;
@@ -125,7 +127,8 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
this.connectionProfile.Add(this.ConnectionProfileName, new ConnectionProfile
{
SubscriptionKey = this.SubscriptionKeyTextBox.Text,
- SubscriptionKeyRegion = this.SubscriptionRegionTextBox.Text,
+ AuthorizationToken = this.AuthorizationTokenTextBox.Text,
+ SubscriptionRegion = this.SubscriptionRegionTextBox.Text,
CustomCommandsAppId = this.CustomCommandsAppIdTextBox.Text,
BotId = this.BotIdTextBox.Text,
ConnectionLanguage = this.LanguageTextBox.Text,
@@ -233,7 +236,8 @@ private void CancelButton_Click(object sender, RoutedEventArgs e)
if (this.connectionProfile.ContainsKey(this.ConnectionProfileComboBox.Text))
{
this.SubscriptionKeyTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKey;
- this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKeyRegion;
+ this.AuthorizationTokenTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].AuthorizationToken;
+ this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionRegion;
this.CustomCommandsAppIdTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].CustomCommandsAppId;
this.BotIdTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].BotId;
this.LanguageTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].ConnectionLanguage;
@@ -252,7 +256,8 @@ private void CancelButton_Click(object sender, RoutedEventArgs e)
else if (!this.connectionProfile.ContainsKey(this.ConnectionProfileComboBox.Text) && this.settings.ConnectionProfileNameHistory.Count > 1)
{
this.SubscriptionKeyTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].SubscriptionKey;
- this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].SubscriptionKeyRegion;
+ this.AuthorizationTokenTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].AuthorizationToken;
+ this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].SubscriptionRegion;
this.CustomCommandsAppIdTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].CustomCommandsAppId;
this.BotIdTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].BotId;
this.LanguageTextBox.Text = this.connectionProfile[this.settings.ConnectionProfileNameHistory[1]].ConnectionLanguage;
@@ -320,6 +325,7 @@ private void UpdateSaveButtonState()
// BUGBUG: The transfer into variables does not seem to be done consistently with these events so we read straight from the controls
var hasConnectionProfileName = !string.IsNullOrWhiteSpace(this.ConnectionProfileComboBox.Text) && this.ConnectionProfileComboBox.Text != " ";
var hasSubscription = !string.IsNullOrWhiteSpace(this.SubscriptionKeyTextBox.Text);
+ var hasAuthToken = !string.IsNullOrWhiteSpace(this.AuthorizationTokenTextBox.Text);
var hasRegion = !string.IsNullOrWhiteSpace(this.SubscriptionRegionTextBox.Text);
var hasUrlOverride = !string.IsNullOrWhiteSpace(this.UrlOverrideTextBox.Text);
@@ -329,9 +335,9 @@ private void UpdateSaveButtonState()
{
this.SaveButtonInfoBlock.Text = "You must provide a profile name";
}
- else if (!hasSubscription)
+ else if (!(hasSubscription ^ hasAuthToken))
{
- this.SaveButtonInfoBlock.Text = "You must provide a speech subscription key.";
+ this.SaveButtonInfoBlock.Text = "You must provide either a speech subscription key or auth token.";
}
else if (!hasRegion && !hasUrlOverride)
{
@@ -468,16 +474,22 @@ private void UpdateWakeWordStatus()
}
}
- private void SubscriptionKeyRegionTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ private void SubscriptionKeyTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
this.UpdateSaveButtonState();
}
- private void SubscriptionKeyTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ private void AuthorizationTokenTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
this.UpdateSaveButtonState();
}
+ private void SubscriptionKeyRegionTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ this.UpdateSaveButtonState();
+ }
+
+
private void CustomCommandsAppIdTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
this.UpdateSaveButtonState();
@@ -511,7 +523,8 @@ private void ConnectionProfileTextBox_TextChanged(object sender, TextChangedEven
if (this.connectionProfile.ContainsKey(this.ConnectionProfileComboBox.Text))
{
this.SubscriptionKeyTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKey;
- this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionKeyRegion;
+ this.AuthorizationTokenTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].AuthorizationToken;
+ this.SubscriptionRegionTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].SubscriptionRegion;
this.CustomCommandsAppIdTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].CustomCommandsAppId;
this.BotIdTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].BotId;
this.LanguageTextBox.Text = this.connectionProfile[this.ConnectionProfileComboBox.Text].ConnectionLanguage;
@@ -539,6 +552,7 @@ private void ConnectionProfileTextBox_TextChanged(object sender, TextChangedEven
private void SetConnectionSettingsTextBoxesToEmpty()
{
this.SubscriptionKeyTextBox.Text = string.Empty;
+ this.AuthorizationTokenTextBox.Text = string.Empty;
this.SubscriptionRegionTextBox.Text = string.Empty;
this.CustomCommandsAppIdTextBox.Text = string.Empty;
this.BotIdTextBox.Text = string.Empty;
@@ -559,7 +573,8 @@ private void SetConnectionSettingsTextBoxesToEmpty()
private void SetProfileSettingsToConnectionSettingsTextBoxes()
{
this.settings.Profile.SubscriptionKey = this.SubscriptionKeyTextBox.Text;
- this.settings.Profile.SubscriptionKeyRegion = this.SubscriptionRegionTextBox.Text;
+ this.settings.Profile.AuthorizationToken = this.AuthorizationTokenTextBox.Text;
+ this.settings.Profile.SubscriptionRegion = this.SubscriptionRegionTextBox.Text;
this.settings.Profile.CustomCommandsAppId = this.CustomCommandsAppIdTextBox.Text;
this.settings.Profile.BotId = this.BotIdTextBox.Text;
this.settings.Profile.ConnectionLanguage = this.LanguageTextBox.Text;