SpeechSynthesisVoice.lang
The lang read-only property of the SpeechSynthesisVoice interface returns a BCP 47 language tag indicating the language of the voice.
Value
A DOMString representing the language of the device.
Examples
for(i = 0; i < voices.length ; i++) {
var option = document.createElement('option');
option.textContent = voices[i].name + ' (' + voices[i].lang + ')';
if(voices[i].default) {
option.textContent += ' -- DEFAULT';
}
option.setAttribute('data-lang', voices[i].lang);
option.setAttribute('data-name', voices[i].name);
voiceSelect.appendChild(option);
}
Specifications
| Specification |
|---|
| Web Speech API # dom-speechsynthesisvoice-lang |
Browser compatibility
BCD tables only load in the browser