Android speech recognition for non-dictionary words -
i developing android application of speech recognition non-dictionary words. want remove dictionary , word. example if pronounce word "pini", current application "beanie". want word recognize pronounced.
my code:
public void onclick(view v) { // todo auto-generated method stub switch (v.getid()) { case r.id.btnspeak: promptspeechinput(); break;} } @override // act on result of tts data check protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == my_data_check_code) { if (resultcode == texttospeech.engine.check_voice_data_pass) { mytts = new texttospeech(this, this); } else { intent installttsintent = new intent(); installttsintent .setaction(texttospeech.engine.action_install_tts_data); startactivity(installttsintent); } } // receiving speech input super.onactivityresult(requestcode, resultcode, data); switch (requestcode) { case req_code_speech_input: { if (resultcode == result_ok && null != data) { arraylist<string> result = data .getstringarraylistextra(recognizerintent.extra_results); txtspeechinput.settext(result.get(0)); } break; } } } @override // act on result of tts data check protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == my_data_check_code) { if (resultcode == texttospeech.engine.check_voice_data_pass) { mytts = new texttospeech(this, this); } else { intent installttsintent = new intent(); installttsintent .setaction(texttospeech.engine.action_install_tts_data); startactivity(installttsintent); } } // receiving speech input super.onactivityresult(requestcode, resultcode, data); switch (requestcode) { case req_code_speech_input: { if (resultcode == result_ok && null != data) { arraylist<string> result = data .getstringarraylistextra(recognizerintent.extra_results); txtspeechinput.settext(result.get(0)); } break; } } } public void speakwords(string speech) { mytts.speak(speech, texttospeech.queue_flush, null); } /** * showing google speech input dialog * */ private void promptspeechinput() { intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); intent.putextra(recognizerintent.extra_language, locale.getdefault()); intent.putextra(recognizerintent.extra_prompt, getstring(r.string.speech_prompt)); try { startactivityforresult(intent, req_code_speech_input); } catch (activitynotfoundexception a) { toast.maketext(getapplicationcontext(), getstring(r.string.speech_not_supported), toast.length_short).show(); } }
any appreciated. thanks.
Comments
Post a Comment