안드로이드
[Android] 문자 읽기(TTS)
코딩하는후운
2022. 10. 20. 14:48
반응형
public void setTTSRead() {
myTTS = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
// check for successful instantiation
if (status == TextToSpeech.SUCCESS) {
MyLogger.LogE("SUCCESS TTS");
if (myTTS.isLanguageAvailable(Locale.KOREAN) == TextToSpeech.LANG_AVAILABLE) {
myTTS.setLanguage(Locale.KOREAN);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ttsGreater21(contents);
} else {
ttsUnder20(contents);
}
} else if (status == TextToSpeech.ERROR) {
MyLogger.LogE("ERROR TTS");
Toast.makeText(AlertMessageActivity.this, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
}
}
});
}
참조 :
http://mainia.tistory.com/1109
http://webnautes.tistory.com/847
반응형