<view>
<u-button class="mic" icon="mic" shape="circle" type="primary" color="#155192"
@touchstart="streamRecord" @touchend="endStreamRecord">长按说话</u-button>
</view>
onShow() {
this.initRecord()
},
streamRecord: function() {
setTimeout(function(){
manager.start({
lang: 'zh_CN',
})
},500)
},
endStreamRecord: function() {
let _that = this
uni.hideLoading()
manager.stop()
},
initRecord: function() {
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)
}
},
每次进页面,按住button录音都不行,一直报错,要等大概一分钟的样子,插件才生效
急死了,有没有大佬指点一下
解决了吗,怎么解决的