开发者

TTS is not looping properly

开发者 https://www.devze.com 2023-03-26 18:51 出处:网络
My requirement: To convert a list of strings into Text to speech.and the start of each string it should play a sound

My requirement: To convert a list of strings into Text to speech.and the start of each string it should play a sound

Problem:Whenever I run this only the last one gets executed and also no music is played inbetween the strings? How should I modify such that the loop will go to next string only when the TexttoSpeech of first string is completed..

   for(int m=0;m<c1;m++)
   {    
       mp = MediaPlayer.create(Web4.this, R.raw.music1);
       mp.start();          
       tts.setOnUtteranceCompletedListener(this);
       HashMap<String, String> myHashRender = new HashMap();
       myHashRender.put(Tex开发者_如何学GotToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,"end of wakeup message ID");
       tts.speak(question1[m],TextToSpeech.QUEUE_FLUSH,myHashRender);
       tts.speak("Completed", TextToSpeech.QUEUE_ADD,        myHashRender);
       mp.stop();
   }


Store the index in a field, and only call the next speak() from onUntteranceCompleted() (except the first one of course).


Try adding delay between each call, it might help.

0

精彩评论

暂无评论...
验证码 换一张
取 消