SpeechRecognitionEvent

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

SpeechRecognitionEvent 介面是 Web Speech API 的一部分,它代表了 resultnomatch 事件的事件物件,幷包含了與臨時或最終語音識別結果相關的所有資料。

Event SpeechRecognitionEvent

建構函式

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

瀏覽器相容性

另見