In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use .net code to achieve speech recognition in the development of Wechat public platform. I hope you will gain something after reading this article. Let's discuss it together.
Voice recognition is an advanced function and can only be realized after Wechat's real name verification. The authentication fee is 300 yuan / year. If you, as a developer, can apply for a test account, it is also possible. First create a Wechat message class, this analogy has an additional 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 a built-in feature of Wechat, which is very powerful and does not require us to do too much:
Protected void Page_Load (object sender, EventArgs e) {wxmessage wx = GetWxMessage (); string res = ""; if (! string.IsNullOrEmpty (wx.EventName) & & wx.EventName.Trim () = "subscribe") {/ / the welcome word string content = "; content =" /: rose welcomes Beijing Yongjie Youxin Technology Co., Ltd. /: rose\ nreply "Hello" directly. Res = sendTextMessage (wx, content);} else {if (wx.MsgType = = "text" & & wx.Content = = "Hello") {res = sendTextMessage (wx, "Hello, welcome to the public Wechat platform of Beijing Yongjie Youxin Technology Co., Ltd.") } else if (wx.MsgType = = "voice") / / recognize that the message type is speech {res = sendTextMessage (wx, wx.Recognition); / / wx.Recognition is the result of speech recognition. We quote it directly and OK it with text feedback} else {res = sendTextMessage (wx, "Hello, failed to recognize the message!") } Response.Write (res);} private wxmessage GetWxMessage () {wxmessage wx = new wxmessage (); StreamReader str = new StreamReader (Request.InputStream, System.Text.Encoding.UTF8); XmlDocument xml = 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, assign the recognition result to the corresponding attribute Recognition {wx.Recognition = xml.SelectSingleNode ("xml"). SelectSingleNode ("Recognition"). InnerText;} return wx of the entity class. } / send text messages / content / private string sendTextMessage (wxmessage wx, string content) {string res = string.Format (@ ", wx.FromUserName, wx.ToUserName, DateTime.Now, content); return res } after reading this article, I believe you have a certain understanding of "how to use .net code to achieve speech recognition in the development of Wechat public platform". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.