Check if speech packages is already in android -
hello i'm building app uses speech recognition, intention is, user can utilize app without internet, need download language bundle within smartphone.
1 - possible check if user has bundle within phone? 2 - can show speech packages scheme configuration user ( wifi or gps configuration )?
to check tts installed . utilize code activity
intent checkttsintent = new intent(); checkttsintent.setaction(texttospeech.engine.action_check_tts_data); checkttsintent.putextra( texttospeech.engine.extra_check_voice_data_for, locale.getdefault()); startactivityforresult(checkttsintent, my_data_check_code);
in onactivityresult add together code checks if tts engine available or not
protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == my_data_check_code) { if (resultcode == texttospeech.engine.check_voice_data_fail) { //tts not installed default language } if (resultcode == texttospeech.engine.check_voice_data_pass) { toast.maketext( getapplicationcontext(), "tts engine info default language installed ", toast.length_long).show(); } else { //tts default language not installed.check other languages if (data != null) { arraylist<string> availablelanguages = info .getstringarraylistextra(texttospeech.engine.extra_available_voices); if (availablelanguages.isempty()) { // no language info available, prompt install showdialog(); } else { // language info available, create tts instance toast.maketext( getapplicationcontext(), "tts engine info default language installed.", toast.length_long).show(); } } }
android speech-recognition text-to-speech
No comments:
Post a Comment