SpeechRecognition: nomatch 事件
Web Speech API 的 nomatch 事件会在语音识别服务返回一个没有显著识别结果的最终结果时触发。
这可能涉及到一定程度的识别,但该识别的 confidence 未达到或超过设定的阈值。
语法
在诸如 addEventListener() 之类的方法中使用事件名称,或设置事件处理程序属性。
js
addEventListener("nomatch", (event) => { })
onnomatch = (event) => { }
事件类型
一个 SpeechRecognitionEvent。继承自 Event。
事件属性
除了下面列出的属性之外,父接口 Event 的属性也可使用。
SpeechRecognitionEvent.emma只读-
返回一个 Extensible MultiModal Annotation markup language (EMMA) — XML — 格式的结果表示。
SpeechRecognitionEvent.interpretation只读-
返回用户所说内容的语义含义。
SpeechRecognitionEvent.resultIndex只读-
返回
SpeechRecognitionResultList"数组" 中已实际发生更改的最低索引值结果。 SpeechRecognitionEvent.results只读-
返回一个
SpeechRecognitionResultList对象,代表当前会话的所有语音识别结果。
示例
您可以在 addEventListener 方法中使用 nomatch 事件
js
const recognition = new (SpeechRecognition || webkitSpeechRecognition)();
recognition.addEventListener("nomatch", () => {
console.error("Speech not recognized");
});
或者使用 onnomatch 事件处理程序属性
js
recognition.onnomatch = () => {
console.error("Speech not recognized");
};
规范
| 规范 |
|---|
| Web Speech API # eventdef-speechrecognition-nomatch |
| Web Speech API # dom-speechrecognition-onnomatch |
浏览器兼容性
加载中…