标签:
官方API:接收语音识别结果
/// <summary> /// 发送响应语音识别结果 /// </summary> /// <param name="requestXML"></param> private void SendVoiceMsg(RequestXML requestXML) { string responseContent = FormatTextXMLForVoice(requestXML.ToUserName, requestXML.FromUserName,DateTime.Now.Year.ToString(),"语音下载接口获得", "您刚才说的语音消息识别结果为:" + requestXML.Recognition.ToString(),"123"); HttpContext.Current.Response.ContentType = "text/xml"; HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; HttpContext.Current.Response.Write(responseContent); HttpContext.Current.Response.End(); } /// <summary> /// 返回格式化的Xml格式语音内容 /// </summary> private string FormatTextXMLForVoice(string ToUserName, string FromUserName, string CreateTime, string MediaId, string Recognition,string MsgId) { return @"<xml><ToUserName><![CDATA["+ToUserName+"]]></ToUserName><FromUserName><![CDATA["+FromUserName+"]]></FromUserName><CreateTime>"+CreateTime+"</CreateTime><MsgType><![CDATA[voice]]></MsgType><MediaId><![CDATA["+MediaId+"]]></MediaId><Format><![CDATA[amr]]></Format><Recognition><![CDATA[{"+Recognition+"}]]></Recognition><MsgId>{"+MsgId+"}</MsgId></xml>"; }
参数 | 描述 |
---|---|
ToUserName | 开发者微信号 |
FromUserName | 发送方帐号(一个OpenID) |
CreateTime | 消息创建时间 (整型) |
MsgType | 语音为voice |
MediaID | 语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体 |
Format | 语音格式:amr |
Recognition | 语音识别结果,UTF8编码 |
MsgID | 消息id,64位整型 |
标签:
原文地址:http://www.cnblogs.com/professional-NET/p/5675084.html