调用搜狗AI开放平台的asr语音识别接口。二进制音频数据已经发送成功,但是接受不到服务器消息。
const recorder=wx.getRecorderManager()
const recordconfig={
frameSize: 25,
sampleRate: 16000,
format: 'WAV',
numberOfChannels: 1
}
const app=getApp()
openSocket: function(){
wx.connectSocket({
url: 'wss://api.zhiyin.sogou.com/wss/asr/v1/streaming_recognize?Appid=1WCCVjJBLB5GzcRIEepsbmxNdgd&Authorization=Bearer '+wx.getStorageSync('token'),
timeout: 600000,
success: res=>{
console.log("连接成功")
}
})
wx.onSocketMessage(res => {
console.log(res)
})
wx.onSocketOpen((result) => {
console.log(result)
let config={
"encoding": "LINEAR16",
"sample_rate_hertz": 16000,
"language_code": "zh-cmn-Hans-CN"
}
let streamconfig={
"config": config,
"interim_results": true
}
wx.sendSocketMessage({
data: JSON.stringify(streamconfig),
success: res=>{
console.log('发送初始帧')
}
})
recorder.start(recordconfig)
recorder.onFrameRecorded(res=>{
wx.sendSocketMessage({
data: wx.arrayBufferToBase64(res.frameBuffer),
success: res=>{
console.log('发送数据帧')
}
})
})
})
}
我现在也有也一样的问题,体验版,接收不到消息、PC开发者工具可以,您解决了吗
我也有同样问题,您后来解决了吗?
假如你是预览不行的话 你试试真机调试跟发布了之后试试