我正在尝试将文本转语音功能添加到我的应用程序中,并且在我从 Google Play 商店更新 TTS 之前它工作正常。
在 onCreate 方法中初始化 TTS 没有任何延迟。更新后,此 TTS 需要 3-5 秒才能完成初始化。基本上,文本转语音直到 3-5 秒后才准备好。
有人可以告诉我我做错了什么吗?
private HashMap<String, String> TTS_ID = new HashMap<String, String>();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.....
.....
TextToSpeech_Initialize();
}
public void TextToSpeech_Initialize() {
TTS_ID.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "UniqueID");
speech = new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS) {
speech.setSpeechRate(SpeechRateValue);
speech.speak(IntroSpeech, TextToSpeech.QUEUE_FLUSH, TTS_ID);
}
}
});
}
非常感谢