微信小程序开发语音识别文字教程

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

微信小程序开发语音识别文字教程

newmiracle宇宙   2019-11-18 我要评论

微信小程序开发语音识别文字教程  

现在后台 添加插件 

微信同声传译

然后app.json

加入插件

"plugins": {
"WechatSI": {
"version": "0.0.7",
"provider": "xxxxxxxxx"
}
}

  

前端页面

  <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',

    })
    console.log('开始录音');
  },
  quxiaoluyin() {
    manager.stop()
    console.log('取消录音');
  },

  

 录音完成后回调

onload函数里面写

 

    manager.onRecognize = function (res) {
      console.log("current result", res.result)
    }
    manager.onStop = function (res) {
// mp3临时路径 console.log("record file path", res.tempFilePath)
//mp3语音转化成文字结果 console.log("result", res.result) } manager.onStart = function (res) { console.log("成功开始录音识别", res) } manager.onError = function (res) { console.error("error msg", res.msg) }

  

详细文档 看https:/https://img.qb5200.com/download-x/developers.weixin.qq.com/miniprogramhttps://img.qb5200.com/download-x/dev/extended/service/translator.html

 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们