Csharp: Baidu speech synthesis and csharp Baidu speech synthesis

Source: Internet
Author: User

Csharp: Baidu speech synthesis and csharp Baidu speech synthesis

Public string API_id = "3333"; // your ID public string API_record = null; public string API_record_format = null; public string API_record_HZ = null; public string API_key = "geovindu "; // your KEY public string API_secret_key = "geovindu"; // your SECRRET_KEY public string API_language = null; public string API_access_token = null; public string strJSON = ""; private const string tex = "the mountains and rivers are far away, And the scenery you love is like the past. "+" Why have you fallen into love, and you have paid off your life and death. "+" Mu Yi Mai lovesickness becomes muddy, Mu Sihai sorrow and no trace. "+" again to the sea of smoke, wonderful Mirror Snow calendar. "; /// <summary> //// </summary> /// <param name = "sender"> </param> /// <param name = "e "> </param> protected void Page_Load (object sender, eventArgs e) {}/// <summary> //// </summary> /// <param name = "sender"> </param> /// <param name = "e"> </param> protected void button#click (object sender, eventArgs e) {API_access_token = getStrAccess (API_key, API_secret_key); Guid cid = new Guid (); Response. redirect (" http://tsn.baidu.com/text2audio?tex= "+ Tex +" & lan = zh & cuid = "+ cid. toString () + "& ctp = 1 & tok =" + API_access_token );} /// <summary> ///// </summary> /// <param name = "para_API_key"> your KEY </param> /// <param name = "para_API_secret_key"> your SECRRET_KEY </param> // <returns> </returns> public string getStrAccess (string para_API_key, string para_API_secret_key) {// method parameter description: // para_API_key: API_key (your KEY) // para_API_secret_key (your SECRRET_KEY) // method return value description: // Baidu authentication password, access_token string access_html = null; string access_token = null; string getAccessUrl =" https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials "+" & Client_id = "+ para_API_key +" & client_secret = "+ para_API_secret_key; try {HttpWebRequest getAccessRequest = WebRequest. create (getAccessUrl) as HttpWebRequest; // getAccessRequest. proxy = null; getAccessRequest. contentType = "multipart/form-data"; getAccessRequest. accept = "*/*"; getAccessRequest. userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 ;. net clr 2.0.50727) "; getAccessRequest. timeout = 30000; // if the connection fails in 30 seconds, the getAccessRequest is interrupted. method = "post"; HttpWebResponse response = getAccessRequest. getResponse () as HttpWebResponse; using (StreamReader strHttpComback = new StreamReader (response. getResponseStream (), Encoding. UTF8) {access_html = strHttpComback. readToEnd () ;}} catch (WebException ex) {Response. write (ex. toString ();} JObject jo = JObject. parse (access_html); access_token = jo ["access_token"]. toString (); // get the returned toke return access_token ;}

The program is not complete yet.

API request methods

Http://yuyin.baidu.com/docs/tts/136

 

The speech synthesis interface supports POST and GET methods.
Official Address: http://tsn.baidu.com/text2audio

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.