首页 > 解决方案 > Artyom.js 立即禁用自身

问题描述

所以我在使用语音库 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 会立即停止语音识别。

提前致谢 :)

标签: javascripthtmlcssvoice-recognition

解决方案


推荐阅读