Voice reading, which is a good feature that can achieve some of the customer's special requirements. It takes just a few simple pieces of code to make the idea function on Android.
The use of speech-reading in Android only requires the use of such Texttospeech, which implements a lot of speech-related functions, which must be set for the language, the support Language list is located in the local class of the Java.util class, as follows:
Screen problems, display insufficient, you can go to the SDK to view. Although the support of a number of ideas list, but seemingly android built-in voice reading language is not much, is not in the future to write the system in the time or how, this does not know why, at present I only test the Chinese and Chinese. Chinese is feasible, Chinese failed. OK, nonsense not much to say, on all implementation code:
Code highlighting produced by Actipro Codehighlighter (freeware) http://www.CodeHighlighter.com/-->package Com.terry;Import Java.util.locale;import Android.app.activity;import android.os.bundle;import Android.speech.tts.texttospeech;import Android.speech.tts.texttospeech.oninitlistener;import Android.util.Log; Import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.EditText; Public classSpeechactivity extends Activity {PrivateTexttospeech Mspeech; PrivateButton btn; PrivateEditText Medittext; /** Called when the activity is first created.*/@Override Public voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.main); BTN=(Button) Findviewbyid (R.ID.BUTTON01); Medittext=(EditText) Findviewbyid (r.id.edittext01); Btn.setenabled (false); Mspeech=NewTexttospeech ( This,NewOninitlistener () {@Override Public voidOnInit (intstatus) { //TODO auto-generated Method Stub if(Status = =texttospeech.success) {intresult =mspeech.setlanguage (locale.english); if(Result = =Texttospeech.lang_missing_data|| result = =texttospeech.lang_not_supported) {LOG.E ("Lanagetag"," not use"); } Else{btn.setenabled (true); Mspeech.speak ("I Love you", Texttospeech.queue_flush,NULL); } } } }); Btn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method StubMspeech.speak (Medittext.gettext (). toString (), Texttospeech.queue_flush,NULL); } }); } @Overrideprotected voidOnDestroy () {//TODO auto-generated Method Stub if(Mspeech! =NULL) {mspeech.stop (); Mspeech.shutdown (); } Super.ondestroy (); }}
Android for easy Voice reading