|
@@ -42,8 +42,8 @@ public class MTTSManager implements TextToSpeech.OnInitListener {
|
|
AppLogUtils.e(true, "TTS语音播报", "语音内容为空 ");
|
|
AppLogUtils.e(true, "TTS语音播报", "语音内容为空 ");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ AppLogUtils.e(false, "TTS语音播报", "TTS语音播报内容 : " + text);
|
|
if (ismServiceConnectionUsable(mTTS)) {
|
|
if (ismServiceConnectionUsable(mTTS)) {
|
|
- AppLogUtils.e(false, "TTS语音播报", "TTS语音播报内容 : " + text);
|
|
|
|
if (mTTS == null) {
|
|
if (mTTS == null) {
|
|
mTTS = new TextToSpeech(MyAppliction.getContext(), this);
|
|
mTTS = new TextToSpeech(MyAppliction.getContext(), this);
|
|
}
|
|
}
|
|
@@ -56,6 +56,10 @@ public class MTTSManager implements TextToSpeech.OnInitListener {
|
|
//TextToSpeech.QUEUE_FLUSH刷新队列,将之前的队列取消阅读现在的文字
|
|
//TextToSpeech.QUEUE_FLUSH刷新队列,将之前的队列取消阅读现在的文字
|
|
mTTS.speak(text, TextToSpeech.QUEUE_FLUSH, null);
|
|
mTTS.speak(text, TextToSpeech.QUEUE_FLUSH, null);
|
|
} else {//被回收了不可用状态
|
|
} else {//被回收了不可用状态
|
|
|
|
+ if (mTTS != null){
|
|
|
|
+ mTTS.stop();
|
|
|
|
+ mTTS.shutdown();
|
|
|
|
+ }
|
|
mTTS = new TextToSpeech(MyAppliction.getContext(), status -> {
|
|
mTTS = new TextToSpeech(MyAppliction.getContext(), status -> {
|
|
if (status == TextToSpeech.SUCCESS) {
|
|
if (status == TextToSpeech.SUCCESS) {
|
|
int result = mTTS.setLanguage(Locale.CHINA);
|
|
int result = mTTS.setLanguage(Locale.CHINA);
|
|
@@ -63,7 +67,11 @@ public class MTTSManager implements TextToSpeech.OnInitListener {
|
|
&& result != TextToSpeech.LANG_AVAILABLE) {
|
|
&& result != TextToSpeech.LANG_AVAILABLE) {
|
|
AppLogUtils.e(true, " TTS - onInit", "TTS语音播报 onInit: 不支持这种语言");
|
|
AppLogUtils.e(true, " TTS - onInit", "TTS语音播报 onInit: 不支持这种语言");
|
|
}
|
|
}
|
|
- mTTS.speak(text, TextToSpeech.QUEUE_FLUSH, null, "jiance");
|
|
|
|
|
|
+ //设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规
|
|
|
|
+ mTTS.setPitch(1.0f);
|
|
|
|
+ //设置语速
|
|
|
|
+ mTTS.setSpeechRate(1.0f);
|
|
|
|
+ mTTS.speak(text, TextToSpeech.QUEUE_FLUSH, null);
|
|
} else {
|
|
} else {
|
|
AppLogUtils.e(true, " TTS - onInit", "TTS语音播报 onInit: TTS初始化失败");
|
|
AppLogUtils.e(true, " TTS - onInit", "TTS语音播报 onInit: TTS初始化失败");
|
|
}
|
|
}
|