最近在调试微信语音翻译插件
按照官方给的demo,自己写了一个一样的,但是始终在报错please wait recognition finished
每次进入业务页面的时候,首次点击录音,接口就直接报please wait recognition finished,文档里给的报错说明也很清楚,说是因为上一次语音任务还未执行完成,所以报错,可是我这是首次进页面,还没操作,控制面板里也没看到插件发送请求。
后面通过这个报错提示,尝试性的在初始化的时候,先调用了一次stop方法,然后就通了,然后就通了,然后就通了。。。。。。。。
initRecord: function() {
manager.stop() //问题就是这里,加上这个就行了
uni.authorize({
scope: 'scope.record',
success(res) {
console.log(res)
}
})
//有新的识别内容返回,则会调用此事件
manager.onRecognize = (res) => {
console.log(res, "onrec")
let text = res.result
this.currentText = text
}
manager.onStart = () => {
uni.showLoading({
title: "正在说话"
})
}
// 识别结束事件
manager.onStop = (res) => {
let text = res.result
if (text == '') {
return
}
this.currentText = text
let re =
/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/g;
text = text.replace(re, "");
this.getBusinessList(text)
}
manager.onError = function(res) {
console.log("error msg", res)
}
}