Android TTS speech synthesis implemented in Chinese version

Source: Internet
Author: User

The Android system supports TTS (text-to-speech), which is speech synthesis, starting with version 1.6. But the Android system default TTS engine: Pic TTS does not support Chinese. So we have to install our own TTS engine and voice packet.

In the project, the first use of the hand is said TTS, free version, feel the sound is not stiff, unnatural, incoherent. Paid version of the money to activate, if not activated, the limit can only be 5 words per time, and is not much better than the free version. Finally, the use of the TTS1.0 voice, the pronunciation of a consistent natural, personal feeling is very good, and later use it.

The following methods are used:

1. First download the Voice pack apk, as well as the speech engine apk, installed on the phone.

2. Enter the system settings--voice input and output settings--tick "TTS speech synthesis", the default engine "TTS speech synthesis", the language "Chinese".

Call the TTS API that comes with Android to enable the Chinese version of speech synthesis.

 PackageCom.example.testxunfeitts;ImportJava.util.Locale;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.speech.tts.TextToSpeech;Importandroid.text.Editable;ImportAndroid.text.TextWatcher;ImportAndroid.view.View;ImportAndroid.widget.Button;ImportAndroid.widget.CheckBox;ImportAndroid.widget.EditText;ImportAndroid.widget.Toast; Public classMainactivityextendsActivity {PrivateEditText Medittext =NULL; PrivateButton Readbutton =NULL; PrivateButton Savebutton =NULL; PrivateCheckBox Mcheckbox =NULL; PrivateTexttospeech mtexttospeech=NULL; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                        Setcontentview (R.layout.activity_main); Medittext= (EditText) This. Findviewbyid (R.id.edittext); Readbutton= (Button) This. Findviewbyid (R.id.rbutton); Savebutton= (Button) This. Findviewbyid (R.id.sbutton); Mcheckbox= (CheckBox) This. Findviewbyid (R.id.checkbox); //instance and initialize the TTS objectMtexttospeech=NewTexttospeech ( This,NewTexttospeech.oninitlistener () {@Override Public voidOnInit (intstatus) {                if(status==texttospeech.success) {//set Language for reading aloud                    intSupported=mtexttospeech.setlanguage (locale.us); if((supported!=texttospeech.lang_available) && (supported!=texttospeech.lang_country_available)) {Toast.maketext (mainactivity). This, "does not support the current language! ", 1). Show ();                }                }                            }        }); //Read the Listen buttonReadbutton.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View arg0) {//read the contents of EditTextMtexttospeech.speak (Medittext.gettext (). toString (), Texttospeech.queue_flush,NULL);                }        }); //Save Button ListenerSavebutton.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View arg0) {//save content in EditText as a voice file                intR = Mtexttospeech.synthesizetofile (Medittext.gettext (). toString (),NULL, "/mnt/sdcard/speak.wav"); if(r==texttospeech.success) {toast.maketext (mainactivity. This, "Saved successfully! ", 1). Show ();              }            }        }); //edittext content Change monitoringMedittext.addtextchangedlistener (Mtextwatcher); } @Overrideprotected voidOnDestroy () {Super. OnDestroy (); if(mtexttospeech!=NULL) {Mtexttospeech.shutdown ();//Turn off TTS        }    }        PrivateTextwatcher Mtextwatcher =NewTextwatcher () {@Override Public voidaftertextchanged (Editable s) {//if it's a write-side reading,            if(Mcheckbox.ischecked () && (S.length ()!=0)){              //get all the content of EditTextString T =s.tostring (); Mtexttospeech.speak (T.substring (s.length ()-1), Texttospeech.queue_flush,NULL); }} @Override Public voidBeforetextchanged (Charsequence S,intStartintbefore,intcount) {            //TODO auto-generated Method Stub} @Override Public voidOnTextChanged (Charsequence S,intStartintbefore,intcount) {            //TODO auto-generated Method Stub                    }            }; }

Chinese speech synthesis (TTS) can be divided into two categories:

1. Consistent with the system interface

Consistent with the system interface, the TTS engine is separated from the voice packet data. Like the system's default Pico Tts,svox, Iflytek is like this.

Advantage: The TTS function can be used through the interface provided by the system to facilitate the expansion of many languages.

Cons: Setting the role of speech reading and setting the speed of speaking is to be set through the interface of the system.

2. Not compatible with the system interface

Does not agree with the system interface, will be the engine and voice package into an APK, and then after the installation, through the specified interface to invoke its provided by the Chinese speech synthesis function.

In addition to these two types of methods, there are some direct TTS functionality into a shared library so file, and then through the NDK to invoke the function of TTS. This kind of is better, because there is no need to install the TTS engine and voice packet, and can be directly in the application to set the speaker is male or female, speed and so on. Think of the old version of the Iflytek is in this form, the more representative of the application is "heard" or "VBook".

This paper analyzes the differences between the famous Chinese phonetic synthesis tts in the market:

One, with the system interface is consistent.

1. Voice TTS1.0

This original message fly is not the same as the system interface TTS, the original is in the form of dynamic library, and recently only in the form of this APK debut, the effect of the synthesis of clear and smooth, not blunt, English is also read very good, sounds very comfortable.

2.SVOX

This is also very strong, n many language support, Chinese not only support Mandarin, but also support Cantonese! But some feel the articulation is not very clear, the listening sense is not very good, but fortunately, because most can understand,: http://www.coolapk.com/apk-4192-com.svox.classic.langpack.cmn_chn_fem/

3. Samsung TTS

Support Korean, Chinese and English, each word is more clear articulation, but even when it is not very smooth.

Install the APK and copy the entire SMT folder to the root of the SD card

Yes: Http://115.com/file/e7z2iliv

Two, is the independent apk form exists mainly in the following

1. The voice of Jie Tong Hua

Jie Tong hua Voice is also Chinese pronunciation is better, with the Hkust news fly have a fight. It is called by using the reflection mechanism of Java to use the TTS class that is already installed.

Jebsen Voice TTS speech pack: http://www.yingyong.so/app/3/1917.htm

2. Hand-spoken TTS

The hand is also a standalone TTS engine that seems to support only the Chinese language at this time. It interfaces openly, voice quality is OK. I do not speak TTS, feel the sound is not stiff, unnatural, coherent.

Its use method in the routine inside has the very detailed introduction, the hand says homepage: http://shoushuo.com/index.html

For the first TTS Chinese engine that fits the system interface, after installation, the language pack needs to be installed, and then it has to be set up briefly before it can be used, as follows:

Settings-"Voice input and output-" Text to speech settings, the corresponding TTS engine behind the tick, tick, and then in the "Default engine" set up the TTS you need, then you can listen to the example.

For the second, it usually comes with an activity to listen to the example.

The recommended use of the Iflytek Chinese TTS, with the voice of the sound are more natural, it should be all the best in Chinese TTS.

Android TTS speech synthesis implemented in Chinese version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.