gpt4 book ai didi

javascript - webkitSpeechGrammarList() 真的有效吗?

转载 作者:行者123 更新时间:2023-11-29 19:18:59 26 4
gpt4 key购买 nike

我正在尝试实现 webkitSpeechGrammarList .就像你在下面看到的那样。但是当我说出一个不符合我的语法的词时,我会得到结果而不是"I didn't recognize that color"

var grammar = '#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;'
var recognition = new webkitSpeechRecognition();
var speechRecognitionList = new webkitSpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
//recognition.continuous = false;
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 1;



var diagnostic = document.querySelector('.output');
var bg = document.querySelector('html');


recognition.start();


recognition.onresult = function(event) {
var color = event.results[0][0].transcript;
diagnostic.textContent = 'Result received: ' + color + '.';
bg.style.backgroundColor = color;
}

recognition.onspeechend = function() {
recognition.stop();
}

recognition.onnomatch = function(event) {
diagnostic.textContent = 'I didnt recognise that color.';
}

所以,因为这都是实验技术。我在想..这真的实现了吗?我怎么知道?

最佳答案

此刻语法是ignored .

关于javascript - webkitSpeechGrammarList() 真的有效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33943150/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com