text to speech - No voice TTS in android -
in application, didn't voice
this code,
public class androidtexttospeechactivity extends activity implements texttospeech.oninitlistener { /** called when activity first created. */
private texttospeech tts; private button btnspeak; private edittext txttext; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); tts = new texttospeech(this, this); btnspeak = (button) findviewbyid(r.id.btnspeak); txttext = (edittext) findviewbyid(r.id.txttext); // button on click event btnspeak.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { speakout(); } }); } @override public void ondestroy() { // don't forget shutdown! if (tts != null) { tts.stop(); tts.shutdown(); } super.ondestroy(); } @override public void oninit(int status) { // todo auto-generated method stub if (status == texttospeech.success) { int result = tts.setlanguage(locale.us); // tts.setpitch(5); // set pitch level // tts.setspeechrate(2); // set speech speed rate if (result == texttospeech.lang_missing_data || result == texttospeech.lang_not_supported) { log.e("tts", "language not supported"); } else { btnspeak.setenabled(true); speakout(); } } else { log.e("tts", "initilization failed"); } } private void speakout() { string text = txttext.gettext().tostring(); tts.speak(text, texttospeech.queue_flush, null); } }
i got error in log cat
language not supported
any 1 me?? , need highlight word when speaking
i got solution, problem locales available on android default tts engine did not match on phone. installed tts engine , works fine it.
or
// missing data, install intent installintent = new intent(); installintent.setaction( texttospeech.engine.action_install_tts_data); startactivity(installintent); refs:
Comments
Post a Comment