Chinese pronunciation of TTS in Android notes
1. TTS is Text to Speech, which converts Text content into Speech. Google started to support TTS in Android 1.6, but unfortunately, it only supports five languages, including English, French, and German. We only have Chinese characters. Therefore, we can only develop our own Chinese speech package program.
Currently, the following types of TTS are available. (1) open source project eyes-free, the link is: http://code.google.com/p/eyes-free/ on the phone installed eyes-free provided by the TTS Service Extended.apk file, you can set the eSpeak input as the default voice input on the phone-set-Voice Input.
The actual results were not tested. Other online users said the results were poor. Specific how to develop, please refer to this article: http://blog.csdn.net/ichliebephone/article/details/6373184
(2) KEDA xunfei is well-known because Apple's speech synthesis has made it a hit. It is also a good company in domestic speech synthesis. Previously, the Chinese Speech engine developed by Android was provided. But I cannot find it now.
(3) TTS is a Chinese Speech engine on the Android platform that provides conversion from Chinese Text to Speech.
TTS is used to read Chinese text, including simplified Chinese and traditional Chinese characters, Arabic numerals, English letters, and symbols. It also handles the problem of Chinese Multi-tone conversion and other issues. What my studio does. Because he provides more detailed secondary development interfaces, I am developing a Chinese TTS for him. In actual tests, the effect is satisfactory. Mandarin is really not very good. In addition, only the latest version has a coherent function. Previously, I had to spend half a day.
The following describes the debugging process and source code.
Step 1: Install the TTS installation package
Install it on your real phone or mobile phone simulator.
Step 2: Download The TTS client class library package
Download the class library shoushuotts. jar Of The TTS client.
Introduce the jar file to your application.
Step 3: 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. and Roid. tts. ITts;/*** @ version 1.0 */public class Speech extends Activity {private ITts ttsService; private boolean ttsBound; private ServiceConnection connection = new ServiceConnection () {@ Override public void onServiceConnected (ComponentName className, IBinder iservice) {ttsService = ITts. stub. asInterface (iservice); ttsBound = true; // call the following initialize method in the first place where the application uses TTS. The second Activity does not need to be called here. Try {ttsService. initialize ();} catch (RemoteException e) {e. printStackTrace (); setTitle ("error") ;}@ Override public void onServiceDisconnected (ComponentName arg0) {ttsService = null; ttsBound = false ;}}; private EditText edt; private Button press; @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); this. setContentVie W (R. layout. main); this. press = (Button) findViewById (R. id. speech); edt = (edittext=findviewbyid(r.id.txt); // Add the event listener Button to the Button. onClickListener () // process event press. setOnClickListener (new OnClickListener () {@ Override public void onClick (View source) {try {ttsService. speak ("welcome", 0);} catch (RemoteException e) {// TODO Auto-generated catch block e. printStackTrace () ;}}) ;}@ Override p Rotected 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 to talk about the TTS apk program, because the old version does not have the function of coherent reading, it is quite stiff.
In addition, note that when you import the shoushuo Development Kit, if you encounter the following error, threadid = 1: thread exiting with uncaught exception (group = 0x4001d800)