|
[插件使用]
bvRecognizer模块:VAD is not available
[复制链接]
本帖最后由 touchx 于 2022-1-17 17:58 编辑
使用百度语音识别模块bvRecognizer,无法语音识别,出错信息为:"VAD is not available"- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
- <title>Hello APP</title>
- <link rel="stylesheet" type="text/css" href="./css/api.css" />
- <style type="text/css">
-
- html,
- body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240, 240, 240, 1.0);
- border-color: rgba(220, 220, 220, 1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240, 240, 240, 0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <br></br>
- <br></br>
- <a class="button" tapmode="active" onclick="fnstartWakeup()">开始唤醒</a>
- <a class="button" tapmode="active" onclick="stopWakeup()">结束唤醒</a>
- <a class="button" tapmode="active" onclick="fnstartListening()">开始识别</a>
- <a class="button" tapmode="active" onclick="fnstopListening()">结束识别</a>
- <a class="button" tapmode="active" onclick="fncancel()">取消识别</a>
- <a class="button" tapmode="active" onclick="fnsetVolumeChangeListener()">设置音量监听</a>
- </div>
- </body>
- <script type="text/javascript">
- //setVolumeChangeListener设置音量监听
- function fnsetVolumeChangeListener() {
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.setVolumeChangeListener(function(ret) {
- console.log(JSON.stringify(ret));
- });
- }
- //startWakeup开始唤醒
- function fnstartWakeup() {
- console.log('========== startWakeup开始唤醒 ==============')
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.startWakeup({
- wakeupFilePath: 'widget://res/WakeUp.bin'
- }, function(ret,err) {
- if(err){
- console.error(JSON.stringify(err))
- }else{
- console.info(JSON.stringify(ret));
-
-
- }
-
-
- });
- }
- //stopWakeup结束唤醒
- function stopWakeup() {
- console.log('========== stopWakeup结束唤醒 ==============')
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.stopWakeup(function(ret) {
- console.log(JSON.stringify(ret));
- });
- }
- //startListening开始语音识别
- function fnstartListening() {
- console.log('========== 开始语音识别 ==============')
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.startListening({
- //infile: 'fs://luyin1.pcm',
- outfile: 'fs://outfile.pcm',
- VadEndPoint: 800,
- language: 'cmn-Hans-CN',
- }, function(ret) {
- console.info(JSON.stringify(ret)); //android 此处出错: {"code":3,"descMessage":"VAD is not available"}
- });
- }
- //stopListening停止语音识别;
- function fnstopListening() {
- console.log('========== stopListening停止语音识别 ==============')
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.stopListening();
- }
- //cancel取消语音识别;
- function fncancel() {
- console.log('========== cancel取消语音识别 ==============')
- var bvRecognizer = api.require('bvRecognizer');
- bvRecognizer.cancel();
- }
- </script>
- </html>
复制代码
|
|