Commit b5528c19 by Kunj Gupta

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

parent 53caff81
......@@ -3,6 +3,7 @@ package com.vsoft.servicenow.chat;
import android.content.Context;
import android.media.AudioManager;
import android.speech.tts.TextToSpeech;
import com.vsoft.servicenow.utils.Util;
import java.util.HashMap;
......@@ -45,6 +46,8 @@ public class Speaker implements TextToSpeech.OnInitListener {
}
public void speak(String text) {
//remove all special characters.
String speakText = text.replaceAll("---*", "");
// Speak only if the TTS is ready
// and the user has allowed speech
if (ready && allowed) {
......@@ -52,7 +55,7 @@ public class Speaker implements TextToSpeech.OnInitListener {
hash.put(TextToSpeech.Engine.KEY_PARAM_STREAM,
String.valueOf(AudioManager.STREAM_MUSIC));
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
@Override
public void onDroidSpeechFinalResult(String finalSpeechResult) {
mInputMessageView.setText(finalSpeechResult);
mInputMessageView.setText(firstLetterCaps(finalSpeechResult));
attemptSend();
}
......@@ -522,5 +522,11 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
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