我正在Android中开发TextToSpeech。我使用以下代码,它工作正常。
public void EnableTextToSpeech(){
//TextToSpeech
text_to_speech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS){
Log.d(TAG,"TextToSpeech init SUCCESS");
int result = text_to_speech.setLanguage(Locale.US);
text_to_speech.setPitch(1);
text_to_speech.setSpeechRate(1);
if(result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED){
Log.d(TAG,"TextToSpeech NOT SUPPORT");
}else {
Log.d(TAG,"TextToSpeech Enable");
String welcome = "Welcome";
text_to_speech.speak(welcome , TextToSpeech.QUEUE_FLUSH,null,"TEST");
}
}else {
Log.d(TAG,"TextToSpeech init FAIL");
}
}
});
}
但是我想用一句话来说多种语言,如中文和英文。
我可以设置与以下代码不同的语言吗?
text_to_speech.setLanguage(Locale.CHINESE);
text_to_speech.setLanguage(Locale.US);
如何在Android中TextToSpeech
的句子中设置和说多种语言?