TextToSpeech setLanguage无法正常工作?

KIS*_*_ZE 5 java android locale text-to-speech google-text-to-speech

我正在设置我的TextToSpeech使用特定语言(英语 - 英国),使用语言环境"en_GB".但它总是使用我的设备默认语言.有没有办法以编程方式设置它?我已下载该语言所需的文件,当我将TTS的默认语言更改为"英语 - 英国"时,它可以正常工作,但是当默认值不同时,编程方法不起作用.我已尽力浏览网页,但无法解决此问题.

    String ttsEngine = "com.google.android.tts";
    txt2Speech = new TextToSpeech(this, this, ttsEngine);
    //Locale ttsLocale = new Locale("eng", "GBR");
    txt2Speech.setLanguage(new Locale("en_GB"));
Run Code Online (Sandbox Code Playgroud)

尝试了几种方法,但都没有.我不能以编程方式设置我的TTS语言吗?

谢谢

编辑:回应'A Honey Bustard'

其他代码:

public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener
Run Code Online (Sandbox Code Playgroud)

我的 onInit()

public void onInit(int status) {
    // TODO Auto-generated method stub

}
Run Code Online (Sandbox Code Playgroud)

我的初始化时,我也会打电话给.setLanguage()我.那是对的吗?我也只打电话一次.每次都不需要打电话吗?我也正在测试GS7onCreate()TextToSpeech

bra*_*all 5

文本转语音引擎正确初始化后,您需要设置语言。

public void onInit(int status) {

    switch (status) {

        case SUCCESS:
        // Set the language here
        break;
        case ERROR:
         // Something went wrong. You can't set the language
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

应该可以做到这一点。