MDN self-hosted library · e01.org

SpeechSynthesisVoice: lang property

Web Speech API

Open notebook · 1 cells web-api-instance-property upstream source

Web Speech API

The lang read-only property of the SpeechSynthesisVoice interface returns a BCP 47 language tag indicating the language of the voice.

Value

A string representing the language of the device.

Examples

for (const voice of voices) {
  const option = document.createElement("option");
  option.textContent = `${voice.name} (${voice.lang})`;

  if (voice.default) {
    option.textContent += " — DEFAULT";
  }

  option.setAttribute("data-lang", voice.lang);
  option.setAttribute("data-name", voice.name);
  voiceSelect.appendChild(option);
}

Specifications

Browser compatibility

See also