Following this Method......
private TextToSpeech tts; tts = new TextToSpeech(this, this);
public void onInit(int status) {
// TODO Auto-generated method stub if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); //tts.setPitch(0.5f); // set pitch level tts.setSpeechRate(1); // set speech speed rate if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "Language is not supported"); } else { speakOut(); } } else { Log.e("TTS", "Initilization Failed"); } } @Override public void onDestroy() { // Don't forget to shutdown! if (tts != null) { tts.stop(); tts.shutdown(); } super.onDestroy(); } private void speakOut() { tts.speak(traintime, TextToSpeech.QUEUE_ADD, null); tts.speak(bustime, TextToSpeech.QUEUE_ADD, null); }
I would suggest adding some
logging into your code to see where it is failing.
Firstly, try putting tts = null; after tts.shutdown(); in onDestroy()
If that doesn't work, check the
status onInit. At the moment your code handles success, but you appear
to do nothing if you get a fail message message.
Put logging in the OnStart and OnInit to check you are correctly calling them - it may be an
error somewhere in your code that you are not detailing above.
|
Speak failed not bound to TTS Engine
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment