|
|
@@ -118,19 +118,16 @@ public class XunFeiMoudle extends ReactContextBaseJavaModule {
|
|
|
|
|
|
@ReactMethod
|
|
|
public void textToSpeech(final String text) {
|
|
|
- if (mTts != null) {
|
|
|
- mTts.startSpeaking(text, null);
|
|
|
- } else {
|
|
|
+ if (mTts == null) {
|
|
|
if (SpeechUtility.getUtility() == null) {
|
|
|
createUtility(mContext);
|
|
|
}
|
|
|
mTts = getSpeechSynthesizer(mContext);
|
|
|
- if (mTts != null) {
|
|
|
- mTts.startSpeaking(text, null);
|
|
|
- } else {
|
|
|
- Toast.makeText(mContext, "语音播报mTts初始化失败", Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ if (mTts != null) {
|
|
|
+ mTts.startSpeaking(text, null);
|
|
|
+ } else {
|
|
|
+ Toast.makeText(mContext, "语音播报mTts初始化失败", Toast.LENGTH_SHORT).show();
|
|
|
}
|
|
|
}
|
|
|
|