Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 16499b1

Browse files
authored
Merge pull request #3377 from microsoft/u/olmidy/config
Update speech configuration to new schema
2 parents a355b51 + 5c626a6 commit 16499b1

File tree

10 files changed

+99
-98
lines changed

10 files changed

+99
-98
lines changed

docs/_docs/clients-and-channels/clients/virtual-assistant-client.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,24 @@ There are two configuration files used to provide your environment settings.
3535
{:.no_toc}
3636
```json
3737
{
38-
"service_key": "SPEECH_SERVICE_SUBSCRIPTION_KEY", // Replace with your Speech Service subscription key
39-
"service_region": "westus2",
40-
"bot_id": "DIRECT_LINE_SPEECH_SECRET_KEY", // Replace with your Direct Line Speech secret
41-
"custom_commands_app_id": "", // Optional, if you are connecting to a Custom Commands application
42-
"custom_voice_deployment_ids": "", // Optional, to point to custom voices
43-
"custom_speech_recognition_endpoint_id": "", // Optional, to point to a customized speech recognition endpoint
44-
"barge_in_supported": false, // Whether or not to listen to keyword while TTS is playing. If true, TTS playback stops once Keyword is verified.
45-
"user_id": "android",
46-
"user_name": "Android",
47-
"locale": "en-us",
48-
"keyword": "computer",
49-
"enableKWS": false, // Keyword spotting
50-
"linkedAccountEndpoint": "" // Optional if you enabled the Linked Accounts solution in the prerequisites
38+
"SpeechSubscriptionKey": "SPEECH_SERVICE_SUBSCRIPTION_KEY", // Replace with your Speech Service subscription key
39+
"SpeechRegion": "westus2",
40+
"BotId": "DIRECT_LINE_SPEECH_SECRET_KEY", // Replace with your Direct Line Speech secret
41+
"CustomCommandsAppId": "", // Optional, if you are connecting to a Custom Commands application
42+
"CustomVoiceDeploymentIds": "", // Optional, to point to custom voices
43+
"CustomSREndpointId": "", // Optional, to point to a customized speech recognition endpoint
44+
"TTSBargeInSupported": false, // Whether or not to listen to keyword while TTS is playing. If true, TTS playback stops once Keyword is verified.
45+
"SpeechSDKLogEnabled": false, // Optional, whether to log Direct Line Speech activites. The default file path is on the device internal storage at Android/data/com.microsoft.bot.builder.solutions.virtualassistant/files/SpeechSDK.log
46+
"UserId": "android",
47+
"UserName": "Android",
48+
"SRLanguage": "en-us",
49+
"Keyword": "computer",
50+
"EnableKWS": false, // Keyword spotting
51+
"LinkedAccountEndpoint": "" // Optional if you enabled the Linked Accounts solution in the prerequisites
5152
}
5253
```
5354

54-
The **user_id** is a unique identifier for all messages generated by the user, this can be combined with [Linked Accounts sample]({{site.baseurl}}/solution-accelerators/samples/linked-accounts/).
55+
The **UserId** is a unique identifier for all messages generated by the user, this can be combined with [Linked Accounts sample]({{site.baseurl}}/solution-accelerators/samples/linked-accounts/).
5556

5657
#### [App configuration]({{site.repo}}/blob/master/samples/android/clients/VirtualAssistantClient/app/src/main/assets/default_app_configuration.json)
5758
{:.no_toc}

samples/android/clients/VirtualAssistantClient/app/src/main/java/com/microsoft/bot/builder/solutions/virtualassistant/activities/main/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected void onCreate(Bundle savedInstanceState) {
137137
// Options hidden in the nav-drawer
138138
Configuration speechConfig = configurationManager.getConfiguration();
139139
enableKws = speechConfig.enableKWS;
140-
bargeInSupported = speechConfig.bargeInSupported;
140+
bargeInSupported = speechConfig.ttsBargeInSupported;
141141
switchEnableKws.setChecked(enableKws);
142142
switchEnableBargeIn.setChecked(bargeInSupported);
143143

@@ -443,7 +443,7 @@ public void onCheckedChangedEnableBargeIn(CompoundButton button, boolean checked
443443
bargeInSupported = checked;
444444

445445
Configuration speechConfig = configurationManager.getConfiguration();
446-
speechConfig.bargeInSupported = bargeInSupported;
446+
speechConfig.ttsBargeInSupported = bargeInSupported;
447447
configurationManager.setConfiguration(speechConfig);
448448
}
449449
}

samples/android/clients/VirtualAssistantClient/app/src/main/java/com/microsoft/bot/builder/solutions/virtualassistant/activities/settings/SettingsActivity.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
public class SettingsActivity extends BaseActivity {
5050

5151
// VIEWS
52-
@BindView(R.id.service_key) TextInputEditText serviceKey;
53-
@BindView(R.id.service_region) TextInputEditText serviceRegion;
52+
@BindView(R.id.speech_subscription_key) TextInputEditText serviceKey;
53+
@BindView(R.id.speech_region) TextInputEditText serviceRegion;
5454
@BindView(R.id.custom_commands_app_id) TextInputEditText customCommandsAppId;
5555
@BindView(R.id.custom_voice_deployment_ids) TextInputEditText customVoiceDeploymentIds;
5656
@BindView(R.id.custom_sr_endpoint_id) TextInputEditText customSpeechRecognitionEndpointId;
5757
@BindView(R.id.user_id) TextInputEditText userId;
58-
@BindView(R.id.locale) TextInputEditText locale;
58+
@BindView(R.id.sr_language) TextInputEditText srLanguage;
5959
@BindView(R.id.history_linecount) TextInputEditText historyLinecount;
6060
@BindView(R.id.switch_enable_sdk_logging) SwitchCompat switchEnableSdkLogging;
6161
@BindView(R.id.spinner_timezone) Spinner spinnerTimezone;
@@ -134,7 +134,7 @@ protected void serviceConnected() {
134134
showAppConfiguration();
135135
}
136136

137-
@OnEditorAction({R.id.history_linecount, R.id.service_key, R.id.service_region, R.id.user_id, R.id.locale, R.id.custom_commands_app_id, R.id.custom_voice_deployment_ids, R.id.custom_sr_endpoint_id})
137+
@OnEditorAction({R.id.history_linecount, R.id.speech_subscription_key, R.id.speech_region, R.id.user_id, R.id.sr_language, R.id.custom_commands_app_id, R.id.custom_voice_deployment_ids, R.id.custom_sr_endpoint_id})
138138
boolean onEditorAction(int actionId, KeyEvent key){
139139
boolean handled = false;
140140
if (actionId == EditorInfo.IME_ACTION_SEND || (key != null && key.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
@@ -321,13 +321,13 @@ private void updateShapeColor(View view, int color){
321321
private void showConfiguration(){
322322
configuration = configurationManager.getConfiguration();
323323

324-
serviceKey.setText(configuration.serviceKey);
325-
serviceRegion.setText(configuration.serviceRegion);
324+
serviceKey.setText(configuration.speechSubscriptionKey);
325+
serviceRegion.setText(configuration.speechRegion);
326326
customCommandsAppId.setText(configuration.customCommandsAppId);
327327
customVoiceDeploymentIds.setText(configuration.customVoiceDeploymentIds);
328-
customSpeechRecognitionEndpointId.setText(configuration.customSpeechRecognitionEndpointId);
328+
customSpeechRecognitionEndpointId.setText(configuration.customSREndpointId);
329329
userId.setText(configuration.userId);
330-
locale.setText(configuration.locale);
330+
srLanguage.setText(configuration.srLanguage);
331331
switchEnableSdkLogging.setChecked(configuration.speechSdkLogEnabled);
332332

333333
// timezone
@@ -401,13 +401,13 @@ private void showGpsLocationSentDate() {
401401
}
402402

403403
private void saveConfiguration() {
404-
configuration.serviceKey = serviceKey.getText().toString();
405-
configuration.serviceRegion = serviceRegion.getText().toString();
404+
configuration.speechSubscriptionKey = serviceKey.getText().toString();
405+
configuration.speechRegion = serviceRegion.getText().toString();
406406
configuration.customCommandsAppId = customCommandsAppId.getText().toString();
407407
configuration.customVoiceDeploymentIds = customVoiceDeploymentIds.getText().toString();
408-
configuration.customSpeechRecognitionEndpointId = customSpeechRecognitionEndpointId.getText().toString();
408+
configuration.customSREndpointId = customSpeechRecognitionEndpointId.getText().toString();
409409
configuration.userId = userId.getText().toString();
410-
configuration.locale = locale.getText().toString();
410+
configuration.srLanguage = srLanguage.getText().toString();
411411
configuration.speechSdkLogEnabled = switchEnableSdkLogging.isChecked();
412412

413413
// timezone

samples/android/clients/VirtualAssistantClient/app/src/main/res/layout-port/activity_settings.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929
<!-- SPEECH SERVICE SUBSCRIPTION KEY -->
3030
<android.support.design.widget.TextInputLayout
31-
android:id="@+id/service_key_layout"
31+
android:id="@+id/speech_subscription_key_layout"
3232
android:layout_width="match_parent"
3333
android:layout_height="wrap_content"
3434
android:layout_marginTop="16dp"
35-
android:hint="@string/configuration_service_key_hint">
35+
android:hint="@string/configuration_speech_subscription_key_hint">
3636

3737
<android.support.design.widget.TextInputEditText
38-
android:id="@+id/service_key"
38+
android:id="@+id/speech_subscription_key"
3939
android:layout_width="match_parent"
4040
android:layout_height="wrap_content"
4141
android:inputType="textPassword"
@@ -44,14 +44,14 @@
4444

4545
<!-- SPEECH SERVICE SUBSCRIPTION KEY REGION -->
4646
<android.support.design.widget.TextInputLayout
47-
android:id="@+id/service_region_layout"
47+
android:id="@+id/speech_region_layout"
4848
android:layout_width="match_parent"
4949
android:layout_height="wrap_content"
5050
android:layout_marginTop="16dp"
51-
android:hint="@string/configuration_service_region_hint">
51+
android:hint="@string/configuration_speech_region_hint">
5252

5353
<android.support.design.widget.TextInputEditText
54-
android:id="@+id/service_region"
54+
android:id="@+id/speech_region"
5555
android:layout_width="match_parent"
5656
android:layout_height="wrap_content"
5757
android:inputType="textPassword"
@@ -122,16 +122,16 @@
122122
android:imeOptions="actionDone"/>
123123
</android.support.design.widget.TextInputLayout>
124124

125-
<!-- LOCALE -->
125+
<!-- SR LANGUAGE -->
126126
<android.support.design.widget.TextInputLayout
127-
android:id="@+id/locale_layout"
127+
android:id="@+id/sr_language_layout"
128128
android:layout_width="match_parent"
129129
android:layout_height="wrap_content"
130130
android:layout_marginTop="16dp"
131-
android:hint="@string/configuration_locale_hint">
131+
android:hint="@string/configuration_sr_language_hint">
132132

133133
<android.support.design.widget.TextInputEditText
134-
android:id="@+id/locale"
134+
android:id="@+id/sr_language"
135135
android:layout_width="match_parent"
136136
android:layout_height="wrap_content"
137137
android:inputType="text"

samples/android/clients/VirtualAssistantClient/app/src/main/res/layout/activity_settings.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929
<!-- SPEECH SERVICE SUBSCRIPTION KEY -->
3030
<android.support.design.widget.TextInputLayout
31-
android:id="@+id/service_key_layout"
31+
android:id="@+id/speech_subscription_key_layout"
3232
android:layout_width="match_parent"
3333
android:layout_height="wrap_content"
3434
android:layout_marginTop="16dp"
35-
android:hint="@string/configuration_service_key_hint">
35+
android:hint="@string/configuration_speech_subscription_key_hint">
3636

3737
<android.support.design.widget.TextInputEditText
38-
android:id="@+id/service_key"
38+
android:id="@+id/speech_subscription_key"
3939
android:layout_width="match_parent"
4040
android:layout_height="wrap_content"
4141
android:inputType="textPassword"
@@ -44,14 +44,14 @@
4444

4545
<!-- SPEECH SERVICE SUBSCRIPTION KEY REGION -->
4646
<android.support.design.widget.TextInputLayout
47-
android:id="@+id/service_region_layout"
47+
android:id="@+id/speech_region_layout"
4848
android:layout_width="match_parent"
4949
android:layout_height="wrap_content"
5050
android:layout_marginTop="16dp"
51-
android:hint="@string/configuration_service_region_hint">
51+
android:hint="@string/configuration_speech_region_hint">
5252

5353
<android.support.design.widget.TextInputEditText
54-
android:id="@+id/service_region"
54+
android:id="@+id/speech_region"
5555
android:layout_width="match_parent"
5656
android:layout_height="wrap_content"
5757
android:inputType="text"
@@ -122,16 +122,16 @@
122122
android:imeOptions="actionDone"/>
123123
</android.support.design.widget.TextInputLayout>
124124

125-
<!-- LOCALE -->
125+
<!-- SR LANGUAGE -->
126126
<android.support.design.widget.TextInputLayout
127-
android:id="@+id/locale_layout"
127+
android:id="@+id/sr_language_layout"
128128
android:layout_width="match_parent"
129129
android:layout_height="wrap_content"
130130
android:layout_marginTop="16dp"
131-
android:hint="@string/configuration_locale_hint">
131+
android:hint="@string/configuration_sr_language_hint">
132132

133133
<android.support.design.widget.TextInputEditText
134-
android:id="@+id/locale"
134+
android:id="@+id/sr_language"
135135
android:layout_width="match_parent"
136136
android:layout_height="wrap_content"
137137
android:inputType="text"

samples/android/clients/VirtualAssistantClient/app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
<string name="nav_menu_enable_barge_in" translatable="false">Enable Barge-In</string>
3636

3737
<!-- CONFIGURATION -->
38-
<string name="configuration_service_key_hint">Speech Service Subscription Key</string>
39-
<string name="configuration_service_region_hint">Speech Service Subscription Key Region</string>
38+
<string name="configuration_speech_subscription_key_hint">Speech Service Subscription Key</string>
39+
<string name="configuration_speech_region_hint">Speech Service Region</string>
4040
<string name="configuration_custom_commands_hint">Custom Commands App ID</string>
4141
<string name="configuration_voice_deployment_hint">Custom Voice Deployment IDs</string>
4242
<string name="configuration_custom_sr_endpoint_hint">Custom Speech Recognition Endpoint ID</string>
4343
<string name="configuration_bot_id_hint">Direct Line Speech Secret Key</string>
4444
<string name="configuration_voice_name_hint">Voice Name</string>
4545
<string name="configuration_user_id_hint">User From Id</string>
46-
<string name="configuration_locale_hint">Locale</string>
46+
<string name="configuration_sr_language_hint">Speech Recognition Language</string>
4747
<string name="configuration_geolocation_lat_hint">Lat</string>
4848
<string name="configuration_geolocation_lon_hint">Lon</string>
4949
<string name="configuration_chat_history_line_count">Chat history line-count</string>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"service_key": "SPEECH_SERVICE_SUBSCRIPTION_KEY",
3-
"service_region": "westus2",
4-
"custom_commands_app_id": "",
5-
"custom_voice_deployment_ids": "",
6-
"custom_speech_recognition_endpoint_id": "",
2+
"SpeechSubscriptionKey": "SPEECH_SERVICE_SUBSCRIPTION_KEY",
3+
"SpeechRegion": "westus2",
4+
"CustomCommandsAppId": "",
5+
"CustomVoiceDeploymentIds": "",
6+
"CustomSREndpointId": "",
77
"SpeechSDKLogEnabled": false,
8-
"user_id": "android",
9-
"user_name": "Android",
10-
"locale": "en-us",
11-
"keyword": "computer",
12-
"linkedAccountEndpoint": ""
8+
"UserId": "android",
9+
"UserName": "Android",
10+
"SRLanguage": "en-US",
11+
"Keyword": "computer",
12+
"LinkedAccountEndpoint": ""
1313
}

samples/android/clients/VirtualAssistantClient/directlinespeech/src/main/java/com/microsoft/bot/builder/solutions/directlinespeech/ConfigurationManager.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,35 +50,35 @@ public Configuration getConfiguration(){
5050
String json = sharedPreferences.getString(SHARED_PREFS_CONFIGURATION, "{}");
5151
Configuration configuration = gson.fromJson(json, new TypeToken<Configuration>(){}.getType());
5252

53-
if (configuration.serviceKey == null) {
54-
configuration.serviceKey = defaultConfiguration.serviceKey;
53+
if (configuration.speechSubscriptionKey == null) {
54+
configuration.speechSubscriptionKey = defaultConfiguration.speechSubscriptionKey;
5555
}
56-
if (configuration.serviceRegion == null) {
57-
configuration.serviceRegion = defaultConfiguration.serviceRegion;
56+
if (configuration.speechRegion == null) {
57+
configuration.speechRegion = defaultConfiguration.speechRegion;
5858
}
5959
if (configuration.customCommandsAppId == null) {
6060
configuration.customCommandsAppId = defaultConfiguration.customCommandsAppId;
6161
}
6262
if (configuration.customVoiceDeploymentIds == null) {
6363
configuration.customVoiceDeploymentIds = defaultConfiguration.customVoiceDeploymentIds;
6464
}
65-
if (configuration.customSpeechRecognitionEndpointId == null) {
66-
configuration.customSpeechRecognitionEndpointId = defaultConfiguration.customSpeechRecognitionEndpointId;
65+
if (configuration.customSREndpointId == null) {
66+
configuration.customSREndpointId = defaultConfiguration.customSREndpointId;
6767
}
6868
if (configuration.speechSdkLogEnabled == null) {
6969
configuration.speechSdkLogEnabled = defaultConfiguration.speechSdkLogEnabled;
7070
}
71-
if (configuration.bargeInSupported == null) {
72-
configuration.bargeInSupported = false;
71+
if (configuration.ttsBargeInSupported == null) {
72+
configuration.ttsBargeInSupported = false;
7373
}
7474
if (configuration.userId == null) {
7575
configuration.userId = defaultConfiguration.userId;
7676
}
7777
if (configuration.userName == null) {
7878
configuration.userName = defaultConfiguration.userName;
7979
}
80-
if (configuration.locale == null) {
81-
configuration.locale = defaultConfiguration.locale;
80+
if (configuration.srLanguage == null) {
81+
configuration.srLanguage = defaultConfiguration.srLanguage;
8282
}
8383
if (configuration.keyword == null) {
8484
configuration.keyword = defaultConfiguration.keyword;

samples/android/clients/VirtualAssistantClient/directlinespeech/src/main/java/com/microsoft/bot/builder/solutions/directlinespeech/SpeechSdk.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,21 @@ private DialogServiceConfig createDialogServiceConfiguration() {
235235

236236
if (configuration.customCommandsAppId == null || configuration.customCommandsAppId.isEmpty()) {
237237
dialogServiceConfig = BotFrameworkConfig.fromSubscription(
238-
configuration.serviceKey,
239-
configuration.serviceRegion);
238+
configuration.speechSubscriptionKey,
239+
configuration.speechRegion);
240240
} else {
241241
dialogServiceConfig = CustomCommandsConfig.fromSubscription(
242242
configuration.customCommandsAppId,
243-
configuration.serviceKey,
244-
configuration.serviceRegion);
243+
configuration.speechSubscriptionKey,
244+
configuration.speechRegion);
245245
}
246246

247-
dialogServiceConfig.setProperty("SPEECH-RecoLanguage", configuration.locale);
247+
dialogServiceConfig.setProperty("SPEECH-RecoLanguage", configuration.srLanguage);
248248
if (!(configuration.customVoiceDeploymentIds == null || configuration.customVoiceDeploymentIds.isEmpty())) {
249249
dialogServiceConfig.setProperty(PropertyId.Conversation_Custom_Voice_Deployment_Ids, configuration.customVoiceDeploymentIds);
250250
}
251-
if (!(configuration.customSpeechRecognitionEndpointId == null || configuration.customSpeechRecognitionEndpointId.isEmpty())) {
252-
dialogServiceConfig.setServiceProperty("cid", configuration.customSpeechRecognitionEndpointId, ServicePropertyChannel.UriQueryParameter);
251+
if (!(configuration.customSREndpointId == null || configuration.customSREndpointId.isEmpty())) {
252+
dialogServiceConfig.setServiceProperty("cid", configuration.customSREndpointId, ServicePropertyChannel.UriQueryParameter);
253253
}
254254
if (configuration.speechSdkLogEnabled) dialogServiceConfig.setProperty(PropertyId.Speech_LogFilename, localSpeechSdkLogFile.getAbsolutePath());;
255255

@@ -459,7 +459,7 @@ public void requestWelcomeCard() {
459459
private client.model.Activity createEventActivity(String eventname, Object channelData, Object value) {
460460
client.model.Activity activity = new client.model.Activity();
461461
activity.setType(ActivityTypes.EVENT);
462-
activity.setLocale(configuration.locale);
462+
activity.setLocale(configuration.srLanguage);
463463
if (from_user != null) activity.setFrom(from_user);
464464
activity.setChannelData(channelData);
465465
activity.setName(eventname);

0 commit comments

Comments
 (0)