Development of micro-credit public platform speech recognition. NET code resolution _ Practical Skills

Source: Internet
Author: User

speech recognition This function belongs to the advanced function, must the micro-letter real name authentication can realize, the attestation expense 300 yuan/year, if you as the developer may apply for the test account number, also can. First, create a micro-message class, which is preceded by an attribute.

 Class Wxmessage 
  {public 
    string Fromusername {get; set;} 
    public string Tousername {get; set;} 
    public string Msgtype {get; set;} 
    public string EventName {get; set;} 
    public string Content {get; set;}
    public string Recognition {get; set;}
    public string Eventkey {get; set;} 
  } 

speech recognition is the function of the micro-letter, very powerful without us doing too much operation:

protected void Page_Load (object sender, EventArgs e) {wxmessage WX = Getwxmessage ();

     string res = ""; if (!string. IsNullOrEmpty (WX. EventName) && WX.
       Eventname.trim () = = "Subscribe") {//The time of the first attention, used to welcome the word string content = "";
       Content = "/:rose welcome Beijing Yong Jie Friend Letter Technology Co., Ltd./:rose\n directly reply" Hello ";
     res = sendtextmessage (wx, content); else {if (WX. Msgtype = = "Text" && wx.
       Content = = "Hello") {res = Sendtextmessage (wx, "Hello, Welcome to use Beijing Yong Jie Xin Technology Co., Ltd. Public micro-letter platform!"); else if (WX. Msgtype = = "Voice")//Recognition message type is speech {res = Sendtextmessage (WX, WX. recognition);//wx. 
       Recognition is the result of speech recognition, we refer directly to the text form feedback on the OK} else {res = Sendtextmessage (wx, "Hello, Unrecognized message!");
   } Response.Write (res);
     Private Wxmessage Getwxmessage () {wxmessage wx = new Wxmessage ();
     StreamReader str = new StreamReader (Request.inputstream, System.Text.Encoding.UTF8); XmlDocumentXML = new XmlDocument (); Xml.
     Load (str); Wx. Tousername = XML. selectSingleNode ("xml"). selectSingleNode ("Tousername").
     InnerText; Wx. Fromusername = XML. selectSingleNode ("xml"). selectSingleNode ("Fromusername").
     InnerText; Wx. Msgtype = XML. selectSingleNode ("xml"). selectSingleNode ("Msgtype").
     InnerText; if (WX). Msgtype.trim () = = "Text") {WX. Content = XML. selectSingleNode ("xml"). selectSingleNode ("Content").
     InnerText; } if (WX. Msgtype.trim () = = "Event") {WX. EventName = XML. selectSingleNode ("xml"). selectSingleNode ("Event").
     InnerText; } if (WX. Msgtype.trim () = = "Voice")//if it is a voice message, the recognition results are assigned to the corresponding attributes of the entity class recognition {WX. Recognition = XML. selectSingleNode ("xml"). selectSingleNode ("Recognition").
     InnerText;
   return WX; //////sends a text message//////Gets the sender information///content///private string sendtextmessage (Wxmessage wx, String content) {String res = string. Format (@ ", WX.) FRomusername, WX.
     Tousername, DateTime.Now, content);
   return res;
 }

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.