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

Commit 55f4904

Browse files
authored
Enhancements for Build (Virtual Assistant Client ) (#3368)
* Fix dropdown selection of keywords * Make Speech SDK logging configurable on/off; make log locations user accessible * Add UI toggle for sdk logging * Update sdk log file name
1 parent 6d0d116 commit 55f4904

File tree

10 files changed

+61
-8
lines changed

10 files changed

+61
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ public void onServiceDisconnected(ComponentName className) {
219219
protected void initializeAndConnect(){
220220
if (speechServiceBinder != null) {
221221
try {
222-
//speechServiceBinder.initializeSpeechSdk(true);
222+
boolean havePermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
223+
speechServiceBinder.initializeSpeechSdk(havePermission);
223224
speechServiceBinder.connectAsync();
224225
} catch (RemoteException exception){
225226
Log.e(LOGTAG, exception.getMessage());

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class SettingsActivity extends BaseActivity {
5757
@BindView(R.id.user_id) TextInputEditText userId;
5858
@BindView(R.id.locale) TextInputEditText locale;
5959
@BindView(R.id.history_linecount) TextInputEditText historyLinecount;
60+
@BindView(R.id.switch_enable_sdk_logging) SwitchCompat switchEnableSdkLogging;
6061
@BindView(R.id.spinner_timezone) Spinner spinnerTimezone;
6162
@BindView(R.id.color_picker_bot) View colorPickedBot;
6263
@BindView(R.id.color_picker_user) View colorPickedUser;
@@ -327,6 +328,7 @@ private void showConfiguration(){
327328
customSpeechRecognitionEndpointId.setText(configuration.customSpeechRecognitionEndpointId);
328329
userId.setText(configuration.userId);
329330
locale.setText(configuration.locale);
331+
switchEnableSdkLogging.setChecked(configuration.speechSdkLogEnabled);
330332

331333
// timezone
332334
selectTimezone(configuration.currentTimezone);
@@ -406,6 +408,7 @@ private void saveConfiguration() {
406408
configuration.customSpeechRecognitionEndpointId = customSpeechRecognitionEndpointId.getText().toString();
407409
configuration.userId = userId.getText().toString();
408410
configuration.locale = locale.getText().toString();
411+
configuration.speechSdkLogEnabled = switchEnableSdkLogging.isChecked();
409412

410413
// timezone
411414
configuration.currentTimezone = (String)tzAdapter.getItem(spinnerTimezone.getSelectedItemPosition());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private void initializeSpeechSdk(boolean haveRecordAudioPermission){
379379
speechSdk.reset();
380380
}
381381
speechSdk = new SpeechSdk();
382-
File directory = getFilesDir();
382+
File directory = getExternalFilesDir(null);
383383
Configuration configuration = configurationManager.getConfiguration();
384384
speechSdk.initialize(configuration, haveRecordAudioPermission, directory.getPath());
385385
if (configuration.enableKWS) {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@
154154
android:imeOptions="actionDone"/>
155155
</android.support.design.widget.TextInputLayout>
156156

157+
<!-- SPEECH SDK LOGGING SWITCH -->
158+
<LinearLayout
159+
android:layout_width="wrap_content"
160+
android:layout_height="wrap_content"
161+
android:layout_marginTop="16dp">
162+
163+
<TextView
164+
style="@style/TextView.InputLabel"
165+
android:layout_width="wrap_content"
166+
android:layout_height="wrap_content"
167+
android:text="@string/configuration_enable_sdk_logging" />
168+
169+
<android.support.v7.widget.SwitchCompat
170+
android:id="@+id/switch_enable_sdk_logging"
171+
android:layout_width="wrap_content"
172+
android:layout_height="wrap_content" />
173+
174+
</LinearLayout>
175+
157176
<!-- TIMEZONE -->
158177
<LinearLayout
159178
android:layout_width="match_parent"

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@
154154
android:imeOptions="actionDone"/>
155155
</android.support.design.widget.TextInputLayout>
156156

157+
<!-- SPEECH SDK LOGGING SWITCH -->
158+
<LinearLayout
159+
android:layout_width="wrap_content"
160+
android:layout_height="wrap_content"
161+
android:layout_marginTop="16dp">
162+
163+
<TextView
164+
style="@style/TextView.InputLabel"
165+
android:layout_width="wrap_content"
166+
android:layout_height="wrap_content"
167+
android:text="@string/configuration_enable_sdk_logging" />
168+
169+
<android.support.v7.widget.SwitchCompat
170+
android:id="@+id/switch_enable_sdk_logging"
171+
android:layout_width="wrap_content"
172+
android:layout_height="wrap_content" />
173+
174+
</LinearLayout>
175+
157176
<!-- TIMEZONE & LOCATION -->
158177
<LinearLayout
159178
android:layout_width="match_parent"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
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>
50+
<string name="configuration_enable_sdk_logging" translatable="false">Enable Speech SDK Logging</string>
5051
<string name="configuration_timezone">Timezone</string>
5152
<string name="configuration_bot_color">Bot bubble background</string>
5253
<string name="configuration_user_color">User bubble background</string>

samples/android/clients/VirtualAssistantClient/directlinespeech/src/main/assets/default_configuration.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"custom_commands_app_id": "",
55
"custom_voice_deployment_ids": "",
66
"custom_speech_recognition_endpoint_id": "",
7+
"SpeechSDKLogEnabled": false,
78
"user_id": "android",
89
"user_name": "Android",
910
"locale": "en-us",

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ public Configuration getConfiguration(){
6565
if (configuration.customSpeechRecognitionEndpointId == null) {
6666
configuration.customSpeechRecognitionEndpointId = defaultConfiguration.customSpeechRecognitionEndpointId;
6767
}
68+
if (configuration.speechSdkLogEnabled == null) {
69+
configuration.speechSdkLogEnabled = defaultConfiguration.speechSdkLogEnabled;
70+
}
6871
if (configuration.bargeInSupported == null) {
69-
configuration.bargeInSupported = defaultConfiguration.bargeInSupported;
72+
configuration.bargeInSupported = false;
7073
}
7174
if (configuration.userId == null) {
7275
configuration.userId = defaultConfiguration.userId;
@@ -81,7 +84,7 @@ public Configuration getConfiguration(){
8184
configuration.keyword = defaultConfiguration.keyword;
8285
}
8386
if (configuration.enableKWS == null) {
84-
configuration.enableKWS = defaultConfiguration.enableKWS;
87+
configuration.enableKWS = false;
8588
}
8689
if (configuration.linkedAccountEndpoint == null) {
8790
configuration.linkedAccountEndpoint = defaultConfiguration.linkedAccountEndpoint;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.microsoft.bot.builder.solutions.directlinespeech;
22

3-
import android.app.Dialog;
43
import android.os.Handler;
54
import android.os.Looper;
65
import android.util.Log;
@@ -53,7 +52,7 @@ public class SpeechSdk {
5352

5453
// CONSTANTS
5554
private static final String LOGTAG = "SpeechSdk";
56-
public static final String CARBONLOGFILENAME = "carbon.log";
55+
public static final String SPEECHSDKLOGFILENAME = "SpeechSdk.log";
5756
public static final String APPLOGFILENAME = "app.log";
5857
private final int RESPONSE_TIMEOUT_PERIOD_MS = 15 * 1000;
5958

@@ -63,7 +62,7 @@ public class SpeechSdk {
6362
private Synthesizer synthesizer;
6463
private Gson gson;
6564
private ChannelAccount from_user;
66-
private String localCarbonLogFilePath;
65+
private String localSpeechSdkLogPath;
6766
private String localAppLogFilePath;
6867
private String localLogDirectory;
6968
private boolean isConnected;
@@ -74,6 +73,7 @@ public class SpeechSdk {
7473
private ArrayList<CardAction> suggestedActions;
7574
private String dateSentLocationEvent;
7675

76+
private File localSpeechSdkLogFile;
7777
private File localAppLogFile;
7878
private FileWriter streamWriter;
7979

@@ -87,9 +87,10 @@ public void initialize(Configuration configuration, boolean haveRecordAudioPermi
8787
from_user = new ChannelAccount();
8888
from_user.setName(configuration.userName);
8989
from_user.setId(configuration.userId);
90-
this.localCarbonLogFilePath = localLogFileDirectory + "/" + CARBONLOGFILENAME;
90+
this.localSpeechSdkLogPath = localLogFileDirectory + "/" + SPEECHSDKLOGFILENAME;
9191
this.localAppLogFilePath = localLogFileDirectory + "/" + APPLOGFILENAME;
9292
this.localLogDirectory = localLogFileDirectory;
93+
localSpeechSdkLogFile = new File(localSpeechSdkLogPath);
9394
intializeAppLogFile();
9495
initializeSpeech(configuration, haveRecordAudioPermission);
9596
handler = new Handler(Looper.getMainLooper());
@@ -250,6 +251,7 @@ private DialogServiceConfig createDialogServiceConfiguration() {
250251
if (!(configuration.customSpeechRecognitionEndpointId == null || configuration.customSpeechRecognitionEndpointId.isEmpty())) {
251252
dialogServiceConfig.setServiceProperty("cid", configuration.customSpeechRecognitionEndpointId, ServicePropertyChannel.UriQueryParameter);
252253
}
254+
if (configuration.speechSdkLogEnabled) dialogServiceConfig.setProperty(PropertyId.Speech_LogFilename, localSpeechSdkLogFile.getAbsolutePath());;
253255

254256
return dialogServiceConfig;
255257
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public class Configuration {
2929
@Expose
3030
public String customSpeechRecognitionEndpointId;
3131

32+
@SerializedName("SpeechSDKLogEnabled")
33+
@Expose
34+
public Boolean speechSdkLogEnabled;
35+
3236
@SerializedName("barge_in_supported")
3337
@Expose
3438
public Boolean bargeInSupported;

0 commit comments

Comments
 (0)