this.recognition = new webkitSpeechRecognition();
我可以这样开始听:
this.recognition.start();
这就是停止听:
this.recognition.stop();
但是你知道一个函数会在this.recognition
启动时返回true,如果它停止会返回false吗?喜欢"isStarted()"
?
感谢。
答案 0 :(得分:8)
您可以通过在onstart
和onend
事件上引发标记变量来执行此操作:
var recognition = new webkitSpeechRecognition();
var recognizing = false;
recognition.onstart = function () {
recognizing = true;
};
recognition.onend = function () {
recognizing = false;
};
recognition.onerror = function (event) {
recognizing = false;
};
if (recognizing) {
// Do stuff
}