我希望我能在这里说清楚。我有一个数组列表,其中包含我想大声朗读的文本。例如,当列表中有 75 个对象时,在说出第三句话之后,我想单击"停止"并对数组列表的第三个位置执行某些操作,我找不到一种方法来找出文本到语音转换队列已处理队列的 3 行?
if(!sh.Contents.isEmpty()) {
for (String object: sh.Contents) {
sh.CurChapter += 1;
speech(String.valueOf(sh.CurChapter) + " " + object);
//textToSpeech.speak(substr, TextToSpeech.QUEUE_ADD, null, null)
}
} else {
speech( "Section not found!");
}
亲切问候
话筒
在语音数组循环中,将位置用作话语 ID 并将其设置为:
speak(utterances.get(i), TextToSpeech.QUEUE_ADD, yourBundle, String.valueOf(i))
然后在你的UtteranceProgressListener
public static final int DO_ACTION_1 = 0;
public static final int DO_ACTION_5 = 4;
@Override
public void onDone(final String utteranceId) {
switch (Integer.valueOf(utteranceId)) {
case DO_ACTION_1:
// do something
break;
case DO_ACTION_5:
// do something else
break;
default:
// do nothing
break;
}
}