SpeechRecognitionEvent
SpeechRecognitionEvent 接口是 Web Speech API 的一部分,它代表了 result 和 nomatch 事件的事件对象,并包含了与临时或最终语音识别结果相关的所有数据。
构造函数
SpeechRecognitionEvent()-
创建一个新的
SpeechRecognitionEvent对象。
实例属性
SpeechRecognitionEvent 还继承了其父接口 Event 的属性。
SpeechRecognitionEvent.resultIndex只读-
返回
SpeechRecognitionResultList"数组" 中已实际发生更改的最低索引值结果。 SpeechRecognitionEvent.results只读-
返回一个
SpeechRecognitionResultList对象,代表当前会话的所有语音识别结果。
示例
此代码摘自我们的 语音变色器 示例。
js
recognition.onresult = (event) => {
const color = event.results[0][0].transcript;
diagnostic.textContent = `Result received: ${color}.`;
bg.style.backgroundColor = color;
};
规范
| 规范 |
|---|
| Web Speech API # speechreco-event |
浏览器兼容性
加载中…