SpeechRecognitionResultList: length 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

SpeechRecognitionResultList 接口的 length 只读属性返回“数组”的长度,即列表中 SpeechRecognitionResult 对象的数量。

一个数字。

示例

此代码摘自我们的 语音变色器 示例。

js
recognition.onresult = (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;

  console.log(event.results.length);
};

规范

规范
Web Speech API
# dom-speechrecognitionresultlist-length

浏览器兼容性

另见