I have one requirement in which User will have options to select languages for e.g English and French.
App will have set of activities and one background service so when app starts,at that time service will start and TTS engine will get initialize with default language as English in service(onInit() method). I have to set the language which will be set by the user when that particular activity starts.
So how to configure the selected language locale in TTS engine at runtime?
My observation is when service starts at that time only TTS engine get intialize with the default language inside onInit() method and at instance activity is not available so we will not have any configured language details so we can’t do that but actual problem what I am facing is second time onwards how to change the locale of TTS engine(When user selects language from the activity) because we can’t use mTts.setLanguage(Locale.FRENCH) outside of onInit() method as if you call this also it will not reflect changes in TTS.
So please help me out to resolve this issue.
I found this blog post on the Android developer blog:
http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html
They state:
I am not experienced in programming TTS applications in Java but it seems to me that you can prompt your users for their preferred language before you construct or initialize your TTS engine. Using that prompt you should be able to pass a value to your onInit() method that will dictate which language pack you are using.
Is there any reason why you can not reinitialize your TTS engine to the new language when users change languages?
I hope this answer is helpful. Best of luck on your project.