Using the Hkust Voice SDK to achieve the text online synthesis of voice _android

Source: Internet
Author: User
Tags stub

Recently need to use the function of voice broadcast, in Baidu seven weapons Baidu voice and the hkust voice to take into account the accuracy and professionalism, selected Hkust news fly. The Android Development SDK provided by HKUST has two kinds of SDK which integrates its own product voice +, which is powerful but initializes the Voice service module; the other is the pure Development SDK does not integrate the product only needs to import the corresponding jar package to be possible to use. A second SDK was selected, considering that only speech synthesis techniques were used.

The specific code looks like this:

Private SpeechSynthesizer MTTs; private int isspeaking = 0; Mtts= Speechsynthesizer.createsynthesizer (this, null); * * Start Synthesis * * @param view/public void start () {Mtts.setparameter (Speechconstant.voice_name, "Xiaoya
    n "); Mtts.setparameter (Speechconstant.speed, "50");/set speed Mtts.setparameter (Speechconstant.volume, "80");/set volume, Range 0~ Mtts.setparameter (Speechconstant.engine_type, Speechconstant.type_cloud);
  Set Cloud Mtts.startspeaking (Search_word_content.gettext (). toString (). Trim (), msynlistener); }//Synthetic listener private Synthesizerlistener Msynlistener = new Synthesizerlistener () {//Buffer progress callback//percent for buffering progress 0~100,be
    Ginpos is the starting position of the buffered audio in the text, and the endpos indicates the end position of the buffered audio in//text, and info is additional information. @Override public void onbufferprogress (int arg0, int arg1, int arg2, String arg3) {//TODO auto-generated Metho D stub}//Session end callback interface, error is null @Override public void oncompleted (Speecherror arg0) {//TODO A
    uto-generated Method Stub}//Session event callback interface @Override public void onEvent (int arg0, int arg1, int arg2, Bundle arg3) {//TODO Auto-gen erated method Stub}//Start playing @Override public void Onspeakbegin () {//TODO auto-generated method Stu b//Pause playback @Override public void onspeakpaused () {//TODO auto-generated Method stub}//Play
    Progress callback//percent for playback progress 0~100,beginpos for playback audio to begin in the text, Endpos indicates that the playback audio ends in the text//book.
    @Override public void onspeakprogress (int arg0, int arg1, int arg2) {//TODO auto-generated method stub} 
Restore playback callback interface @Override public void onspeakresumed () {//TODO auto-generated Method stub}};
        if (isspeaking = = 0) {start ();
        Gif_no.setvisibility (view.invisible);
        Gif.setvisibility (view.visible);
      isspeaking = 1;
        else if (isspeaking = 1) {//Pause playback mtts.pausespeaking ();
        Gif_no.setvisibility (view.visible); Gif.setvisibility (View.invisible);
      isspeaking = 2;
        else if (isspeaking = 2) {//Continue playing//system.out.println ("...");
        Mtts.resumespeaking ();
        isspeaking = 1;
        Gif_no.setvisibility (view.invisible);
      Gif.setvisibility (view.visible);
    //Cancel synthesis mtts.stopspeaking ();  isspeaking = 0;

Summary, start initialization, set the parameters in the Start method, and then call the stop and continue method, if the text call to cancel the synthesis method, restart method

The above content is small make up for everyone to share the use of Hkust Voice SDK to achieve the full text online synthesis of speech, I hope you like.

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.