Back to Content

SpeechRecognition: maxAlternatives property

files/en-us/web/api/speechrecognition/maxalternatives/index.md

latest826 B
Original Source

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

The maxAlternatives property of the {{domxref("SpeechRecognition")}} interface sets the maximum number of {{domxref("SpeechRecognitionAlternative")}}s provided per {{domxref("SpeechRecognitionResult")}}.

The default value is 1.

Value

A number representing the maximum returned alternatives for each result.

Examples

This code is excerpted from our Speech color changer example.

js
const recognition = new SpeechRecognition();
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 1;

// …

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also