Commit 064686d9 by Kunj Gupta

Fixed - TTS two messages speak issue.

parent 59b3733d
......@@ -31,7 +31,7 @@ android {
defaultConfig {
applicationId "com.vsoft.servicenow"
minSdkVersion 16
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "0.0.29"
......
......@@ -3,9 +3,6 @@ package com.vsoft.servicenow.chat;
import android.content.Context;
import android.media.AudioManager;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.util.Log;
import com.vsoft.servicenow.utils.Util;
import java.util.HashMap;
......@@ -47,14 +44,14 @@ public class Speaker implements TextToSpeech.OnInitListener {
}
}
public void speak(String text){
public void speak(String text) {
// Speak only if the TTS is ready
// and the user has allowed speech
if(ready && allowed) {
HashMap<String, String> hash = new HashMap<String,String>();
if (ready && allowed) {
HashMap<String, String> hash = new HashMap<String, String>();
hash.put(TextToSpeech.Engine.KEY_PARAM_STREAM,
String.valueOf(AudioManager.STREAM_MUSIC));
hash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "UniqueID");
hash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "" + System.currentTimeMillis());
tts.speak(Util.fromHtml(text).toString(), TextToSpeech.QUEUE_ADD, hash);
}
}
......@@ -63,16 +60,16 @@ public class Speaker implements TextToSpeech.OnInitListener {
return tts.isSpeaking();
}
public void stop(){
public void stop() {
tts.stop();
}
public void pause(int duration){
public void pause(int duration) {
tts.playSilence(duration, TextToSpeech.QUEUE_ADD, null);
}
// Free up resources
public void destroy(){
public void destroy() {
tts.shutdown();
}
......
......@@ -246,8 +246,6 @@ public class DroidSpeech {
if (play) {
recognitionProgressView.play();
speechProgressAlertDialog.show();
// confirmLayout.setVisibility(View.GONE);
} else {
recognitionProgressView.stop();
speechProgressAlertDialog.cancel();
......
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