2012-03-14 50 views
2

我正在創建一個將文本轉換爲印度語英語的應用程序。
我從一個網站得到了這個(「英語,印度(en_IN)」)值,但我不知道如何以及在哪裏
將此值設置爲語言環境。請給我提示如何設置這種語言。
有必要改變移動設置或不改變TextToSpeech。
在此先感謝..如何在TextTOSpeech中設置印度英語語言?

回答

4

請確保您只在發生onInit()後設置語言。

使用以下代碼:

private TextToSpeech tts; 
private void createTextToSpeechForIndianEnglish() 
{ 
    tts = new TextToSpeech(context, new OnInitListener() 
    { 
     @Override 
     public void onInit(int status) 
     { 
      if (status == TextToSpeech.SUCCESS) 
      { 
       tts.setLanguage(new Locale("en", "IN")); 
      } else 
      { 
       //failed 
      } 
     } 
    }); 
} 
+0

可以我使用tts.setLanguage(Locale.getDefault());? – 2016-10-11 08:34:52