|
|
@@ -1,8 +1,11 @@ |
|
|
|
const app = getApp() |
|
|
|
import request from '../../utils/request' |
|
|
|
import { scrollToID, keyWordsEnum } from '../../utils/util' |
|
|
|
Page({ |
|
|
|
var plugin = requirePlugin("WechatSI") |
|
|
|
let manager = plugin.getRecordRecognitionManager() |
|
|
|
const record = wx.getRecorderManager() |
|
|
|
|
|
|
|
Page({ |
|
|
|
/** |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
@@ -22,7 +25,8 @@ Page({ |
|
|
|
interval: null, |
|
|
|
promotContentCount: 0, |
|
|
|
completionContentCount: 0, |
|
|
|
noticeText: '' |
|
|
|
noticeText: '', |
|
|
|
inputMode: true |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
@@ -397,6 +401,57 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
voiceMode() { |
|
|
|
manager.start({ duration: 100, lang: "zh_CN" }) |
|
|
|
manager.onStop(res => { |
|
|
|
console.log('已获取麦克风调用权限!'); |
|
|
|
}) |
|
|
|
const inputMode = this.data.inputMode |
|
|
|
this.setData({ |
|
|
|
inputMode: !inputMode |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
speakStart() { |
|
|
|
console.log('按下'); |
|
|
|
wx.showLoading({ |
|
|
|
title: '请说话' |
|
|
|
}) |
|
|
|
manager.start({ duration: 30000, lang: "zh_CN" }) |
|
|
|
manager.onStart = function (res) { |
|
|
|
console.log("成功开始录音识别", res) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
speakEnd() { |
|
|
|
console.log('抬起'); |
|
|
|
wx.hideLoading() |
|
|
|
// wx.showLoading({ |
|
|
|
// title: '正在识别', |
|
|
|
// mask: true |
|
|
|
// }) |
|
|
|
manager.stop() |
|
|
|
}, |
|
|
|
|
|
|
|
initVoiceManager() { |
|
|
|
manager.onRecognize = function (res) { |
|
|
|
console.log("current result", res.result) |
|
|
|
} |
|
|
|
|
|
|
|
manager.onStop = function (res) { |
|
|
|
console.log(res.tempFilePath, 'res'); |
|
|
|
console.log(res.result, 'result'); |
|
|
|
wx.hideLoading() |
|
|
|
} |
|
|
|
|
|
|
|
manager.onError = function (res) { |
|
|
|
console.error("error msg", res.msg) |
|
|
|
wx.showToast({ |
|
|
|
title: '太短了,请描述长一点', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
@@ -409,7 +464,7 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow() { |
|
|
|
|
|
|
|
this.initVoiceManager() |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|