微信同声传译?
发布于 7 年前 作者 tangxiulan 230 次浏览 来自 官方Issues

我用了 微信同声传译 组件

第一次点击 没有 调用 好像 第二次才调用了 翻译出来了

// 语音手指按下
  xqmsyy: function () {
    wx.showToast({
      title: '正在聆听……',
      icon: 'none',
      duration: 60000
    })
    var that = this
    manager.start({
      lang: "zh_CN"
    })
    manager.onStart = function (res) {
    }
    manager.onRecognize = function (res) {
      console.log(res.result)
      that.setData({
        xqms: res.result,
      })
    }
  },
  //手指松开
  xqmsyy2: function () {
    let that = this
    wx.showToast({
      title: '正在识别……',
      icon: 'loading',
      duration: 2000
    })
    manager.onStop = function (res) {
      const tempFilePaths = res.tempFilePath
      console.log(res)
      that.setData({
        xqms: res.result,
      })
      wx.uploadFile({
        url: URL + 'file/qiniuUpload', //仅为示例,非真实的接口地址
        filePath: tempFilePaths,
        name: 'file',
        success(res) {
          const data = JSON.parse(res.data)
          that.setData({
            xqmsyydz: data.url
          })
        }
      })
    }
    manager.stop();
  },

回到顶部