微信同声传译插件onRecognize方法不执行,已经有很多问答了,辛苦官方回答下吧
initRecord() {
console.log(manager);
//有新的识别内容返回,则会调用此事件
manager.onRecognize = (res) => {
console.log('onRecognize: ', res.result);
this.setData({
recordStatus: RECORD_STATUS.ING,
activeText: res.result,
activeTip: '点击下方停止录音'
});
if (recordTimer) {
recordTimer = null;
}
setTimeout(() => {
console.log('handle streamRecordEnd');
this.streamRecordEnd();
}, 2000);
};
// 识别结束事件
manager.onStop = (res) => {
let activeText = res.result;
console.log('manager.onStop: ', activeText);
if(activeText == '') {
activeText = '抱歉,没听清';
activeTip = '点击下方再说一遍吧';
}
this.setData({
recordStatus: RECORD_STATUS.NORMAL,
activeText,
activeTip: ''
});
};
// 识别错误事件
manager.onError = (res) => {
this.setData({
recordStatus: RECORD_STATUS.NORMAL,
activeText: '抱歉,没听清',
activeTip: '点击下方重新发起语音搜索'
});
}
},