Android Chinese TTS Speech Synthesis

Source: Internet
Author: User

The Android system supports speech synthesis in five languages (German, English, Spanish, French, and Italian), excluding Chinese. However, the Android system allows third parties to support TTS in Chinese, therefore, we only need to install a suitable third-party TTS application and set it in the system.

There are also several TTS tools available. In fact, we don't have to worry about which one to choose. At present, we 'd better use "xunfei voice +". The speech is fluent and the language speed is optional, the software is still being updated. For some Android 4.0 systems that may not be able to check the TTS option of xunfei, you only need to install the latest version of xunfei voice +.


Then, you only need to call the TextToSpeech class provided by the system and implement the corresponding interface.

Here is a simple speech synthesis control class. If you create an object, you can directly synthesize and play the text.


The Code is as follows:

package cn.com.bfyb;import java.util.Locale;import android.content.Context;import android.speech.tts.TextToSpeech;import android.widget.Toast;public class TextSpeaker {private Context context;private TextToSpeech tts;public TextSpeaker(final Context context) {// TODO Auto-generated constructor stubthis.context = context;tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {@Overridepublic void onInit(int status) {// TODO Auto-generated method stubif (status == TextToSpeech.SUCCESS){int result = tts.setLanguage(Locale.CHINA);if (result == TextToSpeech.LANG_MISSING_DATA|| result == TextToSpeech.LANG_NOT_SUPPORTED){Toast.makeText(context, "Language is not available.",Toast.LENGTH_SHORT).show();}}}});}public void speak(String text) {tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);}}

Code: http://pan.baidu.com/s/1gdtErQF

Tencent voice + official website download: http://open.voicecloud.cn/speechservice



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.