微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Wit.ai解析来自Messager的语音消息

如何解决Wit.ai解析来自Messager的语音消息

我正在尝试使用Wit.ai解析Messenger中的音频附件,而无法使用Wit将语音转换为文本。

https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api#payload

代码或将Messenger音频文件转换为Java文本的任何其他方式是否有问题?谢谢!

async function parseAudio(audioUrl){
  // POST request to retrieve meaning of voice messages in messenger
  
    request({
        url: 'https://api.wit.ai/speech',qs: {access_token: WIT_TOKEN},method: 'POST',headers: {
        'Content-Type': 'audio/mpeg3','Authorization': 'Bearer ' + WIT_TOKEN,},body: audioUrl
    },function(error,response,body) {
      
      if (error) {
          console.log('Error sending audio messages: ',error)
      } else if (response.body.error) {
          console.log('Error sending audio messages body: ',response.body.error)
      } else {
          console.log('parseAudio: ' +  JSON.stringify(response.body));
          // return text to be parsed
      }
    })

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。