Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what circumstances does TextToSpeech.isSpeaking() return true?

The documentation says "Checks whether the TTS engine is busy speaking."

But I just implemented a call to isSpeaking() in an onUtteranceCompletedListener, where I have at least 10 pending utterances and in none of them did I received true.

Assuming that isSpeaking() actually works as documented, I must conclude that I am calling it incorrectly.

What are the points in which calling TextToSpeech.isSpeaking() returns a valid result?

like image 489
an00b Avatar asked Nov 13 '22 08:11

an00b


1 Answers

Answering myself, thanks to coming across this question (also unanswered):

Problem with isSpeaking() when using Text-to-Speech on Android

The source code of the TtsService class shows:

public boolean isSpeaking() {
  return (mSelf.mIsSpeaking && (mSpeechQueue.size() < 1));
}

Which means the TTS engine not only must be speaking but its utterances queue size must be greater than 0.

like image 64
an00b Avatar answered Nov 16 '22 03:11

an00b