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

Commit

Permalink
Enhancements for Build (Virtual Assistant Client ) (#3368)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
olmidy authored May 15, 2020
1 parent 6d0d116 commit 55f4904
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ public void onServiceDisconnected(ComponentName className) {
protected void initializeAndConnect(){
if (speechServiceBinder != null) {
try {
//speechServiceBinder.initializeSpeechSdk(true);
boolean havePermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
speechServiceBinder.initializeSpeechSdk(havePermission);
speechServiceBinder.connectAsync();
} catch (RemoteException exception){
Log.e(LOGTAG, exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class SettingsActivity extends BaseActivity {
@BindView(R.id.user_id) TextInputEditText userId;
@BindView(R.id.locale) TextInputEditText locale;
@BindView(R.id.history_linecount) TextInputEditText historyLinecount;
@BindView(R.id.switch_enable_sdk_logging) SwitchCompat switchEnableSdkLogging;
@BindView(R.id.spinner_timezone) Spinner spinnerTimezone;
@BindView(R.id.color_picker_bot) View colorPickedBot;
@BindView(R.id.color_picker_user) View colorPickedUser;
Expand Down Expand Up @@ -327,6 +328,7 @@ private void showConfiguration(){
customSpeechRecognitionEndpointId.setText(configuration.customSpeechRecognitionEndpointId);
userId.setText(configuration.userId);
locale.setText(configuration.locale);
switchEnableSdkLogging.setChecked(configuration.speechSdkLogEnabled);

// timezone
selectTimezone(configuration.currentTimezone);
Expand Down Expand Up @@ -406,6 +408,7 @@ private void saveConfiguration() {
configuration.customSpeechRecognitionEndpointId = customSpeechRecognitionEndpointId.getText().toString();
configuration.userId = userId.getText().toString();
configuration.locale = locale.getText().toString();
configuration.speechSdkLogEnabled = switchEnableSdkLogging.isChecked();

// timezone
configuration.currentTimezone = (String)tzAdapter.getItem(spinnerTimezone.getSelectedItemPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private void initializeSpeechSdk(boolean haveRecordAudioPermission){
speechSdk.reset();
}
speechSdk = new SpeechSdk();
File directory = getFilesDir();
File directory = getExternalFilesDir(null);
Configuration configuration = configurationManager.getConfiguration();
speechSdk.initialize(configuration, haveRecordAudioPermission, directory.getPath());
if (configuration.enableKWS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@
android:imeOptions="actionDone"/>
</android.support.design.widget.TextInputLayout>

<!-- SPEECH SDK LOGGING SWITCH -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">

<TextView
style="@style/TextView.InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/configuration_enable_sdk_logging" />

<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_enable_sdk_logging"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

<!-- TIMEZONE -->
<LinearLayout
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@
android:imeOptions="actionDone"/>
</android.support.design.widget.TextInputLayout>

<!-- SPEECH SDK LOGGING SWITCH -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">

<TextView
style="@style/TextView.InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/configuration_enable_sdk_logging" />

<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_enable_sdk_logging"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

<!-- TIMEZONE & LOCATION -->
<LinearLayout
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<string name="configuration_geolocation_lat_hint">Lat</string>
<string name="configuration_geolocation_lon_hint">Lon</string>
<string name="configuration_chat_history_line_count">Chat history line-count</string>
<string name="configuration_enable_sdk_logging" translatable="false">Enable Speech SDK Logging</string>
<string name="configuration_timezone">Timezone</string>
<string name="configuration_bot_color">Bot bubble background</string>
<string name="configuration_user_color">User bubble background</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"custom_commands_app_id": "",
"custom_voice_deployment_ids": "",
"custom_speech_recognition_endpoint_id": "",
"SpeechSDKLogEnabled": false,
"user_id": "android",
"user_name": "Android",
"locale": "en-us",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ public Configuration getConfiguration(){
if (configuration.customSpeechRecognitionEndpointId == null) {
configuration.customSpeechRecognitionEndpointId = defaultConfiguration.customSpeechRecognitionEndpointId;
}
if (configuration.speechSdkLogEnabled == null) {
configuration.speechSdkLogEnabled = defaultConfiguration.speechSdkLogEnabled;
}
if (configuration.bargeInSupported == null) {
configuration.bargeInSupported = defaultConfiguration.bargeInSupported;
configuration.bargeInSupported = false;
}
if (configuration.userId == null) {
configuration.userId = defaultConfiguration.userId;
Expand All @@ -81,7 +84,7 @@ public Configuration getConfiguration(){
configuration.keyword = defaultConfiguration.keyword;
}
if (configuration.enableKWS == null) {
configuration.enableKWS = defaultConfiguration.enableKWS;
configuration.enableKWS = false;
}
if (configuration.linkedAccountEndpoint == null) {
configuration.linkedAccountEndpoint = defaultConfiguration.linkedAccountEndpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.microsoft.bot.builder.solutions.directlinespeech;

import android.app.Dialog;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
Expand Down Expand Up @@ -53,7 +52,7 @@ public class SpeechSdk {

// CONSTANTS
private static final String LOGTAG = "SpeechSdk";
public static final String CARBONLOGFILENAME = "carbon.log";
public static final String SPEECHSDKLOGFILENAME = "SpeechSdk.log";
public static final String APPLOGFILENAME = "app.log";
private final int RESPONSE_TIMEOUT_PERIOD_MS = 15 * 1000;

Expand All @@ -63,7 +62,7 @@ public class SpeechSdk {
private Synthesizer synthesizer;
private Gson gson;
private ChannelAccount from_user;
private String localCarbonLogFilePath;
private String localSpeechSdkLogPath;
private String localAppLogFilePath;
private String localLogDirectory;
private boolean isConnected;
Expand All @@ -74,6 +73,7 @@ public class SpeechSdk {
private ArrayList<CardAction> suggestedActions;
private String dateSentLocationEvent;

private File localSpeechSdkLogFile;
private File localAppLogFile;
private FileWriter streamWriter;

Expand All @@ -87,9 +87,10 @@ public void initialize(Configuration configuration, boolean haveRecordAudioPermi
from_user = new ChannelAccount();
from_user.setName(configuration.userName);
from_user.setId(configuration.userId);
this.localCarbonLogFilePath = localLogFileDirectory + "/" + CARBONLOGFILENAME;
this.localSpeechSdkLogPath = localLogFileDirectory + "/" + SPEECHSDKLOGFILENAME;
this.localAppLogFilePath = localLogFileDirectory + "/" + APPLOGFILENAME;
this.localLogDirectory = localLogFileDirectory;
localSpeechSdkLogFile = new File(localSpeechSdkLogPath);
intializeAppLogFile();
initializeSpeech(configuration, haveRecordAudioPermission);
handler = new Handler(Looper.getMainLooper());
Expand Down Expand Up @@ -250,6 +251,7 @@ private DialogServiceConfig createDialogServiceConfiguration() {
if (!(configuration.customSpeechRecognitionEndpointId == null || configuration.customSpeechRecognitionEndpointId.isEmpty())) {
dialogServiceConfig.setServiceProperty("cid", configuration.customSpeechRecognitionEndpointId, ServicePropertyChannel.UriQueryParameter);
}
if (configuration.speechSdkLogEnabled) dialogServiceConfig.setProperty(PropertyId.Speech_LogFilename, localSpeechSdkLogFile.getAbsolutePath());;

return dialogServiceConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class Configuration {
@Expose
public String customSpeechRecognitionEndpointId;

@SerializedName("SpeechSDKLogEnabled")
@Expose
public Boolean speechSdkLogEnabled;

@SerializedName("barge_in_supported")
@Expose
public Boolean bargeInSupported;
Expand Down

0 comments on commit 55f4904

Please sign in to comment.