내 활동에서 안드로이드의 음성 기술에 텍스트를 구현하려고하지만 이상한 오류가 있습니다. 내 코드에서 아무 소리도들을 수 없다. speak 메서드는 onInit 메서드에 넣을 때만 작동합니다. 그렇지 않으면 말할 수 없습니다. 다음과 같이Android TTS는 말하지 않습니다
내 코드는 다음과 같습니다
public class GameOverActivity extends Activity implements OnInitListener { private TextToSpeech talker; .... talker = new TextToSpeech(this, this); say("Something",false); ... public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { talker.setLanguage(Locale.US); } else if (status == TextToSpeech.ERROR) { Toast.makeText(this,"Error occurred while initializing Text-To-Speech engine", Toast.LENGTH_LONG).show(); } void say(String text, boolean flush) { if(flush == true) { talker.speak(text,TextToSpeech.QUEUE_FLUSH,null); } if(flush == false) { talker.speak(text,TextToSpeech.QUEUE_ADD,null); } }
이상한 것은 내가의 onInit의 말 방법을 배치하면, 그것은 잘 작동한다는 것입니다! TTS는 AudioTrack이 EN-US succusfully 설정 음성 속도 100
에로드 TTSService.setLanguage 을 시작로드)
TtsService.OnCreate (:
나는 결과입니다 로그 캣 신중하고 여기에 감시 그런 다음 아무 일도 일어나지 않습니다.위의 코드가 잘못된 이유는 무엇입니까?
미리 감사드립니다.
초기화를 시작할 때 flush 값은 무엇입니까? – Brian
진실 또는 거짓으로 만들면 아무런 차이가 없습니다. – Nick