Commit 064686d9 by Kunj Gupta

Fixed - TTS two messages speak issue.

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