按文档调用,返回错误码43002, errmsg 为:require POST method
https://developers.weixin.qq.com/doc/offiaccount/Intelligent_Interface/AI_Open_API.html 发送的是 POST 请求,但响应信息为:{"data":{"errcode":43002,"errmsg":"require POST method hint: [dAEevA07172801] rid: 662fb1b5-3b7b9004-4d6d046f"},"header":{"Connection":"keep-alive","Content-Type":"text/plain","Date":"Mon, 29 Apr 2024 14:41:57 GMT","Content-Length":"103"},"statusCode":200,"cookies":[],"accelerateType":"none","errMsg":"request:ok"}。 错误信息与实际情况对不上,请给出详细的调用 demo。 function getSttContent(audioPath: string, accessToken: string): string {
wx.request({
url: `http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext?access_token=${accessToken}&format=&voice_id=${audioPath}&lang=zh_CN`,
method: 'POST',
success: (res) => {
console.log('data: %s', JSON.stringify(res))
// const data = res.data.data
// if (data.errcode !== '0') {
// return;
// }
setTimeout(function() {
wx.request({
url: `http://api.weixin.qq.com/cgi-bin/media/voice/queryrecoresultfortext?access_token=${accessToken}&voice_id=${audioPath}&lang=zh_CN`,
method: 'POST',
success: function(res) {
// 第二个接口请求成功的处理逻辑
console.log("stt 结果: %s", JSON.stringify(res))
},
fail: function(error) {
// 第二个接口请求失败的处理逻辑
}
});
}, 3000); // 等待3秒
}
})
return ""
}