java - TextToSpeech setLanguage not working? -


i setting texttospeech use particular language (english - uk), using locale "en_gb". uses devices default language. there no way set programmatically? have downloaded files required language , when change tts's default language 'english - uk' works when default different programmatic approach not work. have scoured web best unable resolve issue.

    string ttsengine = "com.google.android.tts";     txt2speech = new texttospeech(this, this, ttsengine);     //locale ttslocale = new locale("eng", "gbr");     txt2speech.setlanguage(new locale("en_gb")); 

tried several methods, none working. can not set tts's language programmatically?

thank you

edit: in response 'a honey bustard'

other code:

public class mainactivity extends appcompatactivity implements texttospeech.oninitlistener 

my oninit()

public void oninit(int status) {     // todo auto-generated method stub  } 

also i'm calling .setlanguage() in oncreate(), texttospeech initialized. correct? i'm calling once. not required call every time right? i'm testing on gs7

you need set language once text speech engine has initialised correctly.

public void oninit(int status) {      switch (status) {          case success:         // set language here         break;         case error:          // went wrong. can't set language         break;     } } 

that should it.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -