1, the TTS is text to Speech, the text content into the voice. Google in the Android 1.6 began to support TTS, but unfortunately, only support English, French, German and other five languages, but ya ya wood has our Chinese. Therefore, we can only develop our own Chinese voice package program.
At present, there are several Chinese TTS. (1) Open source projectEyes-free, the link is: http://code.google.com/p/eyes-free/ installed on the phoneEyes-freeprovided by after the TTS Service extended.apk file, you can set the Espeak input as the default voice input in phone-settings-voice input-.
the actual effect is not tested, online has other netizens test said the effect is very poor. For specific development, please refer to this article:http://blog.csdn.net/ichliebephone/article/details/6373184
(2) IflytekThis is more famous, because Apple's speech synthesis makes it a fire, it is also the domestic voice synthesis of a relatively good company. previously provided the Chinese language engine developed by Android. But I can't find it now.
(3) hand-spoken TTSHand said TTS, is the Chinese speech engine under the Android platform, provides the Chinese text to the speech conversion.
The use of hand-spoken TTS for Chinese text reading, including Chinese simple and traditional, Arabic numerals, English letters and some symbols of the mixed reading. It also deals with the problems of Polyphone and pitch conversion in Chinese. Personal Studio. Because he provides a more detailed two-time development interface, so I have done a Chinese TTS development. Actual test, the effect of poor money, Putonghua is really not very good. In addition, only the latest version has a coherent function, the previous did not, tangled me half a day.
The debugging process and source code are given below.
The first step: Install the hand said TTS installation package
From official website http://shoushuo.com/sstts.html download Hand said TTS installation package: shoushuotts.apk.
Install to a real phone or phone simulator.
Step Two: Download hand say TTS Customer Class library package
Download hand say TTS Customer Class Library package: Shoushuotts.jar.
Bring the jar file into your app.
Step three, write the code
Import Android.app.activity;import Android.content.componentname;import Android.content.context;import Android.content.intent;import Android.content.serviceconnection;import Android.os.bundle;import Android.os.ibinder;import Android.os.remoteexception;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;import com.shoushuo.android.tts.itts;/** * @version 1.0 */public Class Speech extends activity{private ITts ttsservice; Private Boolean ttsbound; Private Serviceconnection connection = new Serviceconnection () {@Override public void Onserviceconnec Ted (ComponentName ClassName, IBinder iservice) {ttsservice = ITts.Stub.asInterface (IService); Ttsbound = true; In the application of the first use of TTS, call the following initialize method, for example, if there are//two activity all use the hand to say TTS, then the second activity here does not need to call again. try {ttsservice.initialize (); } catch (RemoteException e) {e.printstacktrace (); Settitle ("wrong"); }} @Override public void onservicedisconnected (ComponentName arg0) {ttsservice = nul L Ttsbound = false; } }; Private EditText EDT; Private Button Press; @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.main); This.setcontentview (R.layout.main); This.press = (Button) Findviewbyid (R.id.speech); EDT = (EditText) Findviewbyid (r.id.txt); Add Event Listener to button Button.onclicklistener ()//Handle event Press.setonclicklistener (new Onclicklistene R () {@Override public void OnClick (View source) { try {ttsservice.speak ("Welcome Child", 0); } catch (RemoteException e) {//TODO auto-generated catch block E.printstacktrace (); } } } ); } @Override protected void OnStart () {suPer.onstart (); if (!ttsbound) {String actionname = "Com.shoushuo.android.tts.intent.action.InvokeTts"; Intent Intent = new Intent (actionname); This.bindservice (Intent, connection, context.bind_auto_create); }} @Override protected void OnDestroy () {if (ttsbound) {ttsbound = false; This.unbindservice (connection); } super. OnDestroy (); } }
Remember to use the latest version of the hand to say the TTS APK program, because the old version does not have a coherent reading function, a word is very stiff.
Also, pay particular attention to the fact that when you import the Shoushuo development package, if you have the following error,Threadid=1:thread exiting with uncaught exception (group=0x4001d800)Workaround:Buildpath->order and Export->select all!!!
Resources
http://blog.csdn.net/ichliebephone/article/details/6373184
Http://www.cnblogs.com/linjiqin/archive/2011/11/01/2231598.html
Http://www.eoeandroid.com/thread-308805-1-1.html
Demo download