onUtteranceCompleted()丢失,如果收到的TTS太长太长、onUtteranceCompleted、TTS

2023-09-07 18:14:11 作者:我们错过了扯淡的未来

我刚刚在Android的TTS引擎观察到无证异常:如果要说出的文本太长(大于4K字符),然后 onUtteranceCompleted()那个特定的话语永远不会到来......

I just observed an "undocumented anomaly" in Android's TTS engine: If the text to be spoken is too long (greater than 4K characters), then onUtteranceCompleted() for that particular utterance will never arrive...

有没有其他人碰到这种?

Has anyone else come across this?

这是一个已知的bug或限制?

Is this a known bug or limitation?

可以做些什么来解决此问题?

What could be done to work around this?

推荐答案

我不知道的限制,如I $讲话的对$ PFER小块(有用的,如果暂停,或者如果活动被暂停)。

I wasn't aware of the limit, as I prefer smaller chunks of speech (useful if pausing or if activity is paused).

当你打电话说,可以将新的话语添加到使用此为queueMode队列的末尾:TextToSpeech.QUEUE_ADD

When you call speak, you can add the new utterance to the end of the queue using this for queueMode: TextToSpeech.QUEUE_ADD

测试以确保该句子没有不同的声音,但是我觉得只是在一个句子后裁切长度将工作自动解析(或字如果需要的话)。

Test to be sure the sentence doesn't sound different, but I think just automatically parsing at the next sentence (or word if needed) after a cutoff length would work.