Small micro-channel application development tutorial text speech recognition
Now add background plugin
Micro-channel simultaneous
Then app.json
Add plugin
"plugins": { "WechatSI": { "version": "0.0.7", "provider": "xxxxxxxxx" } }
Front page
<image class="psearchsp_yuyinbtn" bindtouchstart='luyin' bindtouchend='quxiaoluyin' style="display:{{isshow}}" src="yuyinbtn.png"></image>
js
var plugin = requirePlugin("WechatSI") var manager = plugin.getRecordRecognitionManager()
luyin () { manager.start ({ lang: 'zh_CN', }) the console.log ( 'start recording'); }, quxiaoluyin () { manager.stop () the console.log ( 'recording is canceled "); },
After the recording is finished callback
onload function written inside
= function manager.onRecognize (RES) { the console.log ( "Current Result", res.result) } manager.onStop = function (RES) {
// MP3 temporary route console.log ( "record file path", res.tempFilePath )
// MP3 speech into text result the console.log ( "result", res.result) } manager.onStart = function (RES) { the console.log ( "successful identification start recording", RES) } manager.onError function = (RES) { console.error ( "error MSG", res.msg) }
Detailed documentation see https://developers.weixin.qq.com/miniprogram/dev/extended/service/translator.html