帖子
帖子
用户
博客
课程
显示全部楼层
20
帖子
0
勋章
115
Y币

[插件使用] bvRecognizer模块:VAD is not available

[复制链接]
发表于 2022-1-17 17:53:39
本帖最后由 touchx 于 2022-1-17 17:58 编辑

使用百度语音识别模块bvRecognizer,无法语音识别,出错信息为:"VAD is not available"
  1. <!doctype html>
  2. <html>

  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6.     <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7.     <title>Hello APP</title>
  8.     <link rel="stylesheet" type="text/css" href="./css/api.css" />
  9.     <style type="text/css">
  10.       
  11.         html,
  12.         body {
  13.             height: 100%
  14.         }

  15.         body {
  16.             background-color: #fff;
  17.             margin: 0;
  18.         }

  19.         #wrap {
  20.             height: 100%;
  21.             position: relative;
  22.         }

  23.         #header {
  24.             padding-top: 20px;
  25.             background-color: #5082c2;
  26.             height: 44px;
  27.             position: relative;
  28.         }

  29.         #header h1 {
  30.             font-size: 20px;
  31.             height: 44px;
  32.             line-height: 44px;
  33.             margin: 0em;
  34.             color: #fff;
  35.             margin-left: 100px;
  36.             margin-right: 100px;
  37.             text-align: center;
  38.         }

  39.         #main {
  40.             display: -webkit-box;
  41.             -webkit-box-orient: vertical;
  42.             -webkit-box-pack: center;
  43.         }

  44.         a.button {
  45.             display: -webkit-box;
  46.             -webkit-box-orient: vertical;
  47.             -webkit-box-pack: center;
  48.             -webkit-box-align: center;
  49.             height: 32px;
  50.             margin: 8px;
  51.             background-color: rgba(240, 240, 240, 1.0);
  52.             border-color: rgba(220, 220, 220, 1.0);
  53.             border-width: 2px;
  54.             border-style: solid;
  55.         }

  56.         a.active {
  57.             background-color: rgba(240, 240, 240, 0.7);
  58.         }
  59.     </style>
  60. </head>

  61. <body>
  62.     <div id="wrap">
  63.         <br></br>
  64.         <br></br>
  65.         <a class="button" tapmode="active" onclick="fnstartWakeup()">开始唤醒</a>
  66.         <a class="button" tapmode="active" onclick="stopWakeup()">结束唤醒</a>
  67.         <a class="button" tapmode="active" onclick="fnstartListening()">开始识别</a>
  68.         <a class="button" tapmode="active" onclick="fnstopListening()">结束识别</a>
  69.         <a class="button" tapmode="active" onclick="fncancel()">取消识别</a>
  70.         <a class="button" tapmode="active" onclick="fnsetVolumeChangeListener()">设置音量监听</a>
  71.     </div>
  72. </body>

  73. <script type="text/javascript">

  74.     //setVolumeChangeListener设置音量监听
  75.     function fnsetVolumeChangeListener() {
  76.         var bvRecognizer = api.require('bvRecognizer');
  77.         bvRecognizer.setVolumeChangeListener(function(ret) {
  78.             console.log(JSON.stringify(ret));
  79.         });
  80.     }
  81.     //startWakeup开始唤醒
  82.     function fnstartWakeup() {
  83.       console.log('========== startWakeup开始唤醒 ==============')
  84.         var bvRecognizer = api.require('bvRecognizer');
  85.         bvRecognizer.startWakeup({
  86.             wakeupFilePath: 'widget://res/WakeUp.bin'
  87.         }, function(ret,err) {
  88.           if(err){
  89.             console.error(JSON.stringify(err))
  90.           }else{
  91.             console.info(JSON.stringify(ret));
  92.            
  93.             
  94.           }
  95.          
  96.          
  97.         });
  98.     }
  99.     //stopWakeup结束唤醒
  100.     function stopWakeup() {
  101.       console.log('========== stopWakeup结束唤醒 ==============')
  102.         var bvRecognizer = api.require('bvRecognizer');
  103.         bvRecognizer.stopWakeup(function(ret) {
  104.             console.log(JSON.stringify(ret));
  105.         });
  106.     }
  107.     //startListening开始语音识别
  108.     function fnstartListening() {
  109.       console.log('========== 开始语音识别 ==============')
  110.         var bvRecognizer = api.require('bvRecognizer');
  111.         bvRecognizer.startListening({
  112.             //infile: 'fs://luyin1.pcm',
  113.             outfile: 'fs://outfile.pcm',
  114.             VadEndPoint: 800,
  115.             language: 'cmn-Hans-CN',
  116.         }, function(ret) {
  117.           console.info(JSON.stringify(ret)); //android 此处出错: {"code":3,"descMessage":"VAD is not available"}
  118.         });
  119.     }
  120.     //stopListening停止语音识别;
  121.     function fnstopListening() {
  122.       console.log('========== stopListening停止语音识别 ==============')
  123.         var bvRecognizer = api.require('bvRecognizer');
  124.         bvRecognizer.stopListening();
  125.     }
  126.     //cancel取消语音识别;
  127.     function fncancel() {
  128.       console.log('========== cancel取消语音识别 ==============')
  129.         var bvRecognizer = api.require('bvRecognizer');
  130.         bvRecognizer.cancel();
  131.     }
  132. </script>

  133. </html>
复制代码

380
帖子
4
勋章
6
Y币
config.xml中配置后 ,提交代码重新编译了吗
20
帖子
0
勋章
115
Y币
有重新编译,ios可以正常使用
  1. <meta-data name="com.baidu.speech.APP_ID" value="24461784"/>
  2.   <meta-data name="com.baidu.speech.API_KEY" value="bNCSr9mrc27llqDrknQ72paQ"/>
  3.   <meta-data name="com.baidu.speech.SECRET_KEY" value="paXmYyaN4DdQRcWek9Ha2bgT4dfuXsEO"/>

  4.   <feature name="bvRecognizer">
  5.     <param name="ios_sr_appid" value="24453442"/>
  6.     <param name="ios_sr_apikey" value="WmP3CC0assKGze9MQOT9G3tr"/>
  7.     <param name="ios_sr_secretkey" value="vr29Y0l0fnb3y5ckfs7sNAhXxSn85InQ"/>
  8.   </feature>
复制代码
解决了吗
您需要登录后才可以回帖 登录

本版积分规则