Initialising the TextToSpeech object on a worker thread

前端 未结 1 1761
情深已故
情深已故 2020-12-06 12:28

For years (literally), my application has suffered woes from poorly performing text to speech engines, in particular, the initialisation time when calling:

t         


        
相关标签:
1条回答
  • 2020-12-06 12:49

    I had believed the the TextToSpeech Constructor was asynchronous

    That is only partially true. A lot of the initialization is executed syncronously. Here is the Source

    If this implementation is the way forward, then why don't Google implement it in their TextToSpeechSettings?

    It seems like google seldomly checks how their code runs on mid and lowend devices, I guess the lag doesn't show on highend devices. (Another example of this happening can be seen in the current youtube app, for which I personally can confirm lag on a mid-spec device and no lag on a high-end device.) This is pure speculation as I am not affiliated to google.

    I fear there may be side-effects to this that I've not considered? Can anyone think of any?

    The only (obvious) sideeffect is that you can't use the tts engine syncronously, but have to wait for the asyncronous task to finish. But that is already the case anyway. The only thing you do is execute some code outside of the UI thread, which does not expect to be run on the UI thread. This should never be a problem. And even if there is a problem, you will only find it by testing it in an application.

    In general you're good to go.

    0 讨论(0)
提交回复
热议问题