찾다
위챗 애플릿위챗 개발.Net에서 개발한 WeChat 공개 플랫폼의 음성 인식 사례에 대한 자세한 설명

이 기사는 주로 WeChat 공개 플랫폼에서 개발한 음성 인식 .Net 코드에 대한 자세한 분석을 제공합니다. 관심 있는 친구들은 이를 참고할 수 있습니다.

음성 인식이 기능은 고급입니다. 위챗 실명인증 후에만 구현 가능합니다. 인증 수수료는 연간 300위안입니다. 개발자로서 테스트 계정을 신청할 수도 있습니다. 먼저 WeChat 메시지 클래스를 만듭니다. 이 클래스에는 이전보다 속성이 하나 더 있습니다.

 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; } 
  }

음성 인식은 WeChat에 내장된 기능으로 매우 강력하며 너무 많은 작업을 수행할 필요가 없습니다.

protected void Page_Load(object sender, EventArgs e)
   {
     wxmessage wx = GetWxMessage();
     string res = "";

     if (!string.IsNullOrEmpty(wx.EventName) && wx.EventName.Trim() == "subscribe")
     {//刚关注时的时间,用于欢迎词
       string content = "";
       content = "/:rose欢迎北京永杰友信科技有限公司/:rose\n直接回复“你好”";
       res = sendTextMessage(wx, content);
     }
     else
     {
       if (wx.MsgType == "text" && wx.Content == "你好")
       {
         res = sendTextMessage(wx, "你好,欢迎使用北京永杰友信科技有限公司公共微信平台!");
       }
       else if (wx.MsgType == "voice")//识别消息类型为语音
       {
         res = sendTextMessage(wx, wx.Recognition);//wx.Recognition就是语音识别的结果了,我们直接引用,以文本形式反馈就OK了

       }
       else
       {
         res = sendTextMessage(wx, "你好,未能识别消息!");
       }
     }

     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")//如果是语音消息的话就把识别结果赋值给实体类的相应属性Recognition 
     {
       wx.Recognition = xml.SelectSingleNode("xml").SelectSingleNode("Recognition").InnerText;
     }
     
     return wx;
   }

   ///  
   /// 发送文字消息 
   ///  
   /// 获取的收发者信息 
   /// 内容 
   ///  
   private string sendTextMessage(wxmessage wx, string content)
   {
     string res = string.Format(@" ",
       wx.FromUserName, wx.ToUserName, DateTime.Now, content);
     return res;
   }

위 내용은 .Net에서 개발한 WeChat 공개 플랫폼의 음성 인식 사례에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음