SpeechRecognitionEvent: results 屬性
SpeechRecognitionEvent 介面的只讀屬性 results 返回一個 SpeechRecognitionResultList 物件,該物件代表當前會話的所有語音識別結果。
具體來說,此物件將包含所有已返回的最終結果,後跟所有中間結果當前的最佳猜測。當後續 result 事件觸發時,中間結果可能會被新的中間結果或最終結果覆蓋 — 它們甚至可能被移除,如果它們位於“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 # dom-speechrecognitionevent-results |
瀏覽器相容性
載入中…