async initRecord() {
let that=this
manager.stop()
//有新的识别内容返回,则会调用此事件
manager.onRecognize = (res) => {
console.log('onRecognize',res)
let text = res.result
that.setData({currentText:that.data.currentText+text})
}
// 识别结束事件
manager.onStop = (res) => {
console.log('onStop',res)
let text = res.result
if(text == '') {
// 用户没有说话,可以做一下提示处理
this.showRecordEmptyTip()
return
}
let newText=text.replace(/。/g, "").trim()
let newArr=newText.split('和')
that.setData({
currentText:that.data.currentText+text,
totalTime:res.duration,
})
}
// 识别错误事件
manager.onError = (res) => {
console.log(res,'onError')
this.setData({
recording: false,
bottomButtonDisabled: false,
})
}
},
同问