高级接口--语音识别

开通语音识别功能以后,用户每次发送语音给微信公众账号时,微信会在推送的语音XML数据包中增加一个Recongnition字段。该字段为语音识别除的文本内容。

<xml>
  <ToUserName>< ![CDATA[toUser] ]></ToUserName>
  <FromUserName>< ![CDATA[fromUser] ]></FromUserName>
  <CreateTime>1357290913</CreateTime>
  <MsgType>< ![CDATA[voice] ]></MsgType>
  <MediaId>< ![CDATA[media_id] ]></MediaId>
  <Format>< ![CDATA[Format] ]></Format>
  <Recognition>< ![CDATA[腾讯微信团队] ]></Recognition>
  <MsgId>1234567890123456</MsgId>
</xml>
        elif isinstance(recMsg,ReceiveVoiceMsg):
            print(postStr)
            if recMsg.Recognition is not '':
                content = '你说的是:' + recMsg.Recognition
                replyMsg = ReplyTextMsg(recMsg.FromUserName, recMsg.ToUserName, content)
            else:
                replyMsg = ReplyVoiceMsg(recMsg.FromUserName, recMsg.ToUserName, recMsg.MediaId)

测试账号,不能体验此功能。。。。

猜你喜欢

转载自www.cnblogs.com/ahMay/p/12052489.html