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: '点击下方重新发起语音搜索'
});
}
},