Commit b5528c19 by Kunj Gupta

Fixed - Reading minus minus minus... for underline text.

parent 53caff81
...@@ -3,6 +3,7 @@ package com.vsoft.servicenow.chat; ...@@ -3,6 +3,7 @@ package com.vsoft.servicenow.chat;
import android.content.Context; import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import com.vsoft.servicenow.utils.Util; import com.vsoft.servicenow.utils.Util;
import java.util.HashMap; import java.util.HashMap;
...@@ -45,6 +46,8 @@ public class Speaker implements TextToSpeech.OnInitListener { ...@@ -45,6 +46,8 @@ public class Speaker implements TextToSpeech.OnInitListener {
} }
public void speak(String text) { public void speak(String text) {
//remove all special characters.
String speakText = text.replaceAll("---*", "");
// Speak only if the TTS is ready // Speak only if the TTS is ready
// and the user has allowed speech // and the user has allowed speech
if (ready && allowed) { if (ready && allowed) {
...@@ -52,7 +55,7 @@ public class Speaker implements TextToSpeech.OnInitListener { ...@@ -52,7 +55,7 @@ public class Speaker implements TextToSpeech.OnInitListener {
hash.put(TextToSpeech.Engine.KEY_PARAM_STREAM, hash.put(TextToSpeech.Engine.KEY_PARAM_STREAM,
String.valueOf(AudioManager.STREAM_MUSIC)); String.valueOf(AudioManager.STREAM_MUSIC));
hash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "" + System.currentTimeMillis()); hash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "" + System.currentTimeMillis());
tts.speak(Util.fromHtml(text).toString(), TextToSpeech.QUEUE_ADD, hash); tts.speak(Util.fromHtml(speakText).toString(), TextToSpeech.QUEUE_ADD, hash);
} }
} }
......
...@@ -476,7 +476,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList ...@@ -476,7 +476,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
@Override @Override
public void onDroidSpeechFinalResult(String finalSpeechResult) { public void onDroidSpeechFinalResult(String finalSpeechResult) {
mInputMessageView.setText(finalSpeechResult); mInputMessageView.setText(firstLetterCaps(finalSpeechResult));
attemptSend(); attemptSend();
} }
...@@ -522,5 +522,11 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList ...@@ -522,5 +522,11 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
speaker.destroy(); speaker.destroy();
} }
private String firstLetterCaps ( String data ) {
String firstLetter = data.substring(0,1).toUpperCase();
String restLetters = data.substring(1).toLowerCase();
return firstLetter + restLetters;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment