docs.rodeo

MDN Web Docs mirror

SpeechRecognition: lang property

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

The lang property of the {{domxref("SpeechRecognition")}}  interface returns and sets the language of the current SpeechRecognition. If not specified, this defaults to the HTML lang attribute value, or the user agent’s language setting if that isn’t set either.

Value

A string representing the language for the current SpeechRecognition. The value should be a valid {{glossary("BCP 47 language tag")}} .

Examples

This code is excerpted from our Speech color changer example.

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

// …

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN