Answer the question
In order to leave comments, you need to log in
Why does TextToSpeech throw an error?
Good afternoon, I
wrote a simple code for sound synthesis, I took an example here
Here is my actual code:
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener{
private Button btn;
private TextToSpeech mTTS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)findViewById(R.id.button);
mTTS = new TextToSpeech(this, this);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String text = "А Васька слушает да ест";
mTTS.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
});
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
Locale locale = new Locale("ru");
int result = mTTS.setLanguage(locale);
//int result = mTTS.setLanguage(Locale.getDefault());
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "Извините, этот язык не поддерживается");
} else {
}
} else {
Log.e("TTS", "Ошибка!");
}
}
@Override
public void onDestroy() {
// Don't forget to shutdown mTTS!
if (mTTS != null) {
mTTS.stop();
mTTS.shutdown();
}
super.onDestroy();
}
}
08-04 06:58:50.716 10158-10158/? E/TTS: Извините, этот язык не поддерживается
08-04 06:58:55.056 3176-10171/com.svox.pico E/CompatTtsService: setLanguage(rus,RUS,) failed
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question