zoukankan      html  css  js  c++  java
  • 微信小程序智能语音识别

    1. <span style="font-size:14px;"> startRecode:function(){  
    2.  var s = this;  
    3.  console.log("start");  
    4.  wx.startRecord({  
    5.      success: function (res) {  
    6.          console.log(res);  
    7.          var tempFilePath = res.tempFilePath;  
    8.          s.setData({ recodePath: tempFilePath, isRecode:true});  
    9.      },  
    10.      fail: function (res) {  
    11.          console.log("fail");  
    12.          console.log(res);  
    13.          //录音失败  
    14.      }  
    15.  });  
    16.  },  
    17.  endRecode:function(){//结束录音   
    18.  var s = this;  
    19.  console.log("end");  
    20.  wx.stopRecord();  
    21.  s.setData({ isRecode: false });  
    22.   
    23.     
    24.  wx.showToast();  
    25.  setTimeout(function () {  
    26.      var urls = app.globalData.urls + "/Web/UpVoice";  
    27.      console.log(s.data.recodePath);  
    28.      wx.uploadFile({  
    29.          url: urls,  
    30.          filePath: s.data.recodePath,  
    31.          name: 'file',  
    32.          header: {  
    33.              'content-type': 'multipart/form-data'  
    34.          },  
    35.          success: function (res) {  
    36.              var str = res.data;  
    37.              var data = JSON.parse(str);  
    38.              if (data.states == 1) {  
    39.                  var cEditData = s.data.editData;  
    40.                  cEditData.recodeIdentity = data.identitys;  
    41.                  s.setData({ editData: cEditData });  
    42.              }  
    43.              else {  
    44.                  wx.showModal({  
    45.                      title: '提示',  
    46.                      content: data.message,  
    47.                      showCancel: false,  
    48.                      success: function (res) {  
    49.   
    50.                      }  
    51.                  });  
    52.              }  
    53.              wx.hideToast();  
    54.          },  
    55.          fail: function (res) {  
    56.              console.log(res);  
    57.              wx.showModal({  
    58.                  title: '提示',  
    59.                  content: "网络请求失败,请确保网络是否正常",  
    60.                  showCancel: false,  
    61.                  success: function (res) {  
    62.   
    63.                  }  
    64.              });  
    65.              wx.hideToast();  
    66.          }  
    67.      });  
    68.  },1000)  
    69.   
    70.  }</span>  
  • 相关阅读:
    将ip地址转成二进制数据,除基本输入输出不调用库函数实现
    将ip地址转成二进制数据
    一种合并链表方法实现 严蔚敏 数据结构
    阿里巴巴集团2014年校园招聘系统工程师北京笔试题
    显示模态模态对话框和非模态对话框
    MFC中利用CString和Format成员函数将数字格式化输出
    ObjectARX2012错误1 fatal error C1083: 无法打开包括文件:“arxHeaders.h”: No such file or directory; fatal error C1083: 无法打开包括文件:“map”: No such file or directory
    Metasploit 读书笔记-神器Meterpreter
    解决:kali linux 在vmware 虚拟机中使用bridge模式上网的问题
    metasploit 读书笔记-EXPLOITATION
  • 原文地址:https://www.cnblogs.com/hjjun/p/8033853.html
Copyright © 2011-2022 走看看