//识别语音初始化
initRecord() {
const that = this;
manager.onStart = function (res) {
that.setData({
recordState: true, //录音状态
})
}
manager.onError = function (res) {
that.setData({
recordState: false,
});
const tips = {
'-30003': '说话时间间隔太短,无法识别语音',
'-30004': '没有听清,请再说一次~',
'-30011': '上个录音正在识别中,请稍后尝试',
};
const retcode = res?.retcode.toString();
retcode &&
wx.showToast({
title: tips[`${retcode}`],
icon: 'none',
duration: 2000,
});
}
//识别结束事件
manager.onStop = function (res) {
wx.showModal({
title: '提示',
content: '听不清楚,请重新说一遍!',
showCancel: false,
})
return;
}
let _res = res.result.replace(/[,,。!?,.!?]/g, ' ');
that.setData({
searchKey: _res
})
}
},
//按住说话
touchStart(event) {
manager.start({
duration: 30000,
lang: 'zh_CN',
})
},
//松开结束
touchEnd(e) {
this.setData({
recordState: false,
})
manager.stop();
},
类似的问题,其他人也提过:
https://developers.weixin.qq.com/community/develop/doc/000c26b9988dd87ded50df89d67800?_at=1737084530872
可以尝试提示下用户,用弹窗 loading,临时解决下,然后等官方修复。