Back to Content

SpeechRecognitionResultList

files/en-us/web/api/speechrecognitionresultlist/index.md

latest1.2 KB
Original Source

{{APIRef("Web Speech API")}}

The SpeechRecognitionResultList interface of the Web Speech API represents a list of {{domxref("SpeechRecognitionResult")}} objects, or a single one if results are being captured in {{domxref("SpeechRecognition.continuous","non-continuous")}} mode.

Instance properties

  • {{domxref("SpeechRecognitionResultList.length")}} {{ReadOnlyInline}}
    • : Returns the length of the "array" — the number of {{domxref("SpeechRecognitionResult")}} objects in the list.

Instance methods

  • {{domxref("SpeechRecognitionResultList.item")}}
    • : A standard getter that allows {{domxref("SpeechRecognitionResult")}} objects in the list to be accessed via array syntax.

Examples

This code is excerpted from our Speech color changer example.

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also