내 애플 리케이션에 텍스트 음성을 구현하려고합니다. 다음 가이드를 따라했지만 내 앱은 스플래시 화면 이후 계속 충돌합니다.안드로이드 용 텍스트가 작동하지 않습니다.
링크 : http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/
주요 활동 클래스 내가 가진이
String alertMessage = AppResources.ALERT_MSG;
SpeakDemo speak = new SpeakDemo(null, alertMessage);
speak.speakOut();
나는)합니다 (speak.speakOut를 제거하는 경우; 응용 프로그램이 잘 작동 줄.
응용 프로그램 자원은 다음과 같은 메시지 상자
public static String ALERT_MSG = "Welcome!";
SpeakDemo 클래스가 또 다른 클래스 :
import java.util.Locale;
import android.content.Context;
import android.speech.tts.TextToSpeech;
import android.util.Log;
public class SpeakDemo implements TextToSpeech.OnInitListener{
private TextToSpeech tts;
private Context context;
private String message;
public SpeakDemo(Context context, String message){
this.context = context;
this.message = message;
}
@Override
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "This Language is not supported");
} else {
speakOut();
}
} else {
Log.e("TTS", "Initilization Failed!");
}
}
public void speakOut(){
tts.speak(message, TextToSpeech.QUEUE_FLUSH, null);
}
}
어떤 아이디어?
감사합니다.
도 몇 가지 설명을 제공하십시오. 건배 – d4Rk