问题
On Android, when using a TextToSpeech instance that uses the Google text to speech engine, it seems as though the method isLanguageAvailable() is unreliable.
I say this because there are many instances where this method will return "success" (0,1,or 2), but subsequent speak() commands only results in silence.
The case I am testing is a Samsung S5 with API 23. It is in airplane mode (no network).
I'm assuming that the reason is at least partly because there is no network and therefore it can neither download and install new voices, nor use cloud-based voices.
But then shouldn't isLanguageAvailable() simply return false -- not available?
Assuming there is no network, how am I supposed to check whether a certain Locale and/or Voice is going to be "speakable" or not?
The only way I can think of is to set an utteranceProgressListener on the TextToSpeech instance, send a "test" utterance like "..." and test for an error... but this seems highly unsatisfactory!
It would be nice if there were a way to check which Voices are installed/embedded/READY TO SPEAK.
来源:https://stackoverflow.com/questions/50962724/how-to-predict-failure-of-google-text-to-speech