I have problem with Indonesia text to speech, this is my code
public class ButtonListener {
private final TextToSpeech mTextToSpeech;
private final DictionaryFragment mDictionaryFragment;
private final DictionaryTypeState mDictionaryTypeState;
@BindView(R.id.search_words)
EditText mEditText;
public ButtonListener(DictionaryFragment dictionary, View root) {
ButterKnife.bind(this, root);
this.mDictionaryFragment = dictionary;
this.mTextToSpeech = new TextToSpeech(dictionary.getContext(), null);
this.mDictionaryTypeState = new DictionaryTypeState(dictionary.getContext());
}
@OnClick(R.id.clear_text)
void clearText() {
mEditText.setText(ConstanValues.EMPTY);
mTextToSpeech.stop();
}
@OnClick(R.id.speech_to_text)
void voiceInput() {
openVoiceInput();
}
@OnClick(R.id.text_to_speech)
void speakText() {
mTextToSpeech.setLanguage(getLangue());
mTextToSpeech.speak(mEditText.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);
}
private final Locale getLangue() {
return mDictionaryTypeState.getDictionarySourceState().equals(ConstanValues.ENGLISH_SOURCE)
? Locale.ENGLISH : new Locale("id", "ID");
}
private final void openVoiceInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
.putExtra(RecognizerIntent.EXTRA_LANGUAGE, new Locale("id", "ID"))
.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word");
mDictionaryFragment.startActivityForResult(intent, ConstanValues.REQUEST_CODE);
}
public TextToSpeech getTextToSpeech() {
return mTextToSpeech;
}
}
I made a dictionary application, that can use English and Indonesian text to speech , I made a code for Indonesian, but what appears in the emulator is always English, is there something missing in my code? I beg for your help