HTML内容
需要引入jquery和artyom.window.js
使用方法:打开浏览器,提示你打开麦克风。然后单击按钮,自动会说Master!你说hello,她会问你干啥。
其他命令自己写。
<!DOCTYPE html>
<!-- saved from url=(0060)https://sdkcarlos.github.io/demos/ourcodeworld-artyomjs.html -->
<html lang="zh-CN" class="translated-ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Our Code World">
<script src="jquery-3.6.0.min.js"></script>
<script src="artyom.window.js"></script>
<title>语音助手测试</title>
<body>
<button id="speak" style="width: 100px;height: 50px;">Speak</button>
<script>
const artyom = new Artyom();
document.getElementById("speak").addEventListener("click",
function () {
artyom.say("What can i do for you")
}, false)
artyom.addCommands([{
indexes: ["hello", "hi", "hey"],
action: (i) => {
artyom.say("My Master,I'm here")
}
}, {
indexes: ["Shutdown"],
action: (i, wildcard) => {
artyom.fatality().then(() => {
console.log("11")
});
}
}]);
artyom.initialize({
lang: "en-GB",
continuous: true,
soundex: true,
debug: true,
executionKeyword: "and do it now",
listen: true
}).then(() => {
console.log("success")
}).catch(err => {
console.log("err")
});
</script>
</body>
</html>