1
我正在從事文本到語音的應用,onUtteranceCompleted從未觸發。 這是我的一些代碼:Android文本到語音:onUtteranceCompleted()未解鎖
public class MyActivity extends Activity implements OnInitListener, OnUtteranceCompletedListener {
private TextToSpeech tts;
private HashMap<String, String> hashAudio;
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
//defining hashAudio, its music!
this.hashAudio = new HashMap<String, String>();
this.hashAudio.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_MUSIC));
this.tts.setOnUtteranceCompletedListener(this);
this.readEnglish();
}
}
public void readEnglish(){
Log.v("MESSAGE", "reading english"); //gets shown
this.hashAudio.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "english");
this.tts.setLanguage(Locale.US);
this.tts.speak("TEST", TextToSpeech.QUEUE_FLUSH, this.hashAudio);
//gets read
}
public void onUtteranceCompleted(String uttId) {
Log.v("MESSAGE", "Uterrance Completed");
//never see this message
}
有人會知道爲什麼嗎?我已經通過幾個主題在了這裏有一些解決方案,但沒有工作:(。我也仔細閱讀了Android文檔:(。
謝謝