我正在使用TTS引擎将文本转换为语音,我想暂停TTS语音并恢复语音。我尝试使用sdcard使用synthesizetofile()保存TTS引擎语音并且它工作正常。但我的要求是暂停,恢复TTS引擎语音而不存储到SD卡...请给我任何解决方案
答案 0 :(得分:0)
private void Teks_Ke_Suara_Kontak() {
String text = textkontakAuto.getText().toString();
HashMap<String, String> myHash = new HashMap<String, String>();
myHash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "done");
String[] splitspeech = text.split(" : ");
for (int i = 0; i < splitspeech.length; i++)
{
if (i == 0)
{ // Use for the first splited text to flush on audio stream
SuaraKeTeks.speak(splitspeech[i].toString().trim(),TextToSpeech.QUEUE_FLUSH, myHash);
}
else
{ // add the new test on previous then play the TTS
SuaraKeTeks.speak(splitspeech[i].toString().trim(), TextToSpeech.QUEUE_ADD,myHash);
}
SuaraKeTeks.playSilence(750, TextToSpeech.QUEUE_ADD, null);
}
}