Android Chinese TTS

Source: Internet
Author: User

Now in the development of Android Chinese voice broadcast has a variety of cloud services, SDKs, APIs and so on, but most of the services are required to support the Internet for speech synthesis, in Chinese speech synthesis, Iflytek is undoubtedly the leader, And it also provides downloads for offline speech synthesis packages that need to be paid by distribution and usage time.

The Android native API itself also provides TTS functionality, and we can use the Texttospeech class to broadcast the words you want to pronounce using a few lines of code, as follows:

1, first need to instantiate the Texttospeech class, in the Texttospeech constructor, you need to provide a Oninitlistener object to complete the initialization of the Texttospeech object settings, The OnInit method needs to be implemented in the Oninitlistener object, and we can call the SetLanguage method within the method

To set the language type, Local.china is Chinese, after setting up to determine whether the current system supports the language to be pronounced, the code is as follows:

  @Override  public  void  onInit (int   status) { if  (Status == Texttospeech.success) {  result = Texttospeech.setlanguage (Locale.china);  if  (Result = = Texttospeech.lang_missing_data | | result == texttospeech.lang_not_supported) {Toast.maketext ( this ,  " lang_missing_data or lang_not_supported !  "   

2, then need to pronounce the place call Texttospeech instance Object Speak method can complete the voice broadcast, before the broadcast can be called SetPitch method to set the tone, the default value is 1, the higher the value of the higher the tone, the code is as follows:

// The tone Texttospeech.speak can also be modified in the system setup ("Hello, let's Test the voice function!", texttospeech.queue_flush, NULL);

3, using Texttospeech for voice broadcast use of the language data on the device Android system set up the TTS voice packet, the default is not supported in Chinese, in my test plate for example, the default TTS package is Pico TTS, only support English, French, German, In several languages, such as Italian and Spanish,:

4, the Android system supports the custom third-party TTS Voice Library, we can download and install a "voice of Speech +", and in the system voice settings will be the TTS switch selected as "Voice fly Speech +",:

After that, we will be able to successfully TTS broadcast Chinese!

---done---

Android Chinese TTS

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.