Artyom.js立即禁用自身

时间:2018-08-19 08:57:57

标签: javascript html css voice-recognition

所以在使用语音库Artyom.js时遇到了几个问题。  我尝试添加自己的命令,从理论上讲,这应该可行。但是主要的问题是语音识别在启用后会立即停止。以下是javascript,css和html文件:

var five = require("johnny-five");
var keypress = require("keypress");

    const artyom = new Artyom();

function startArtyom() {
  artyom.initialize({
    lang:"en-GB",
    continous:true,
    debug:true,
    listen:true,
    speed:1,
    mode:"normal"
  }).then(function(){
    console.log("ready!");



  })
}

var commandHello = {
    indexes:["hello","good morning","hey"], // These spoken words will trigger the execution of the command
    action:function(){ // Action to be executed when a index match with spoken word
        artyom.say("Hey buddy ! How are you today?");
    }
};

artyom.addCommands([commandHello]);


/*keypress(process.stdin);*/

/*var board = new five.Board();*/
body {
  font-family: ebrima;
}
#body{
  transition: all 3s ease-in-out;
}
#speech-cont {
  background-color: gray;
  height: 500px;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
  border-radius: 0.5vh;
  padding: 10px;
}

#speech-cont h3 {
  text-align: center;
  color: white;
  font-family: ebrima;
  font-weight: lighter;
}

#speech-cont #box {
  border-style: solid;
  border-color: black;
  border-radius: 0.5vh;
  background-color: white;
  height: 70%;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
  border-width: 1px;
}

#recognizeButton {
  height: auto;
  line-height: 30px;
  width: 200px;
  margin-left: 50%;
  transform: translateX(-50%);
  margin-top: 20px;
}
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">


</head>


<body id="body">
<div id="speech-cont">
<h3>Speech to text recognition</h3>

<div id="box">
<h4 id="result">
</h4>


</div>

<button id="recognizeButton" onclick="startArtyom();">Recognize!</button>
</div>
<script src="artyom.win.min.js"></script>
<script src="main.js"></script>
</body>
</html>

如您所见,我什至直接复制并粘贴了Atryom.js网站中的示例,以查看是否写过错字。事实并非如此。

我绝对不知道为什么artyom.js立即停止语音识别。

预先感谢:)

0 个答案:

没有答案