I am using the Web Speech API for text to speech and need to be able to determine the default voice. To do this I call speechSynthesis.getVoices()
and enumerate the voices to find the one where default is true.
I am in the US an use the US English locale on all of my devices. In Chrome on Windows and Mac the default voice returned is Google US English. However on the Chromebook the default voice returned is Chrome OS German. Is that really the correct default?
Is there some other locale setting on the Chromebook that I'm missing? I have tried changing the default voice for ChromeVox (which was also Chrome OS German before I changed it) but no luck.
Or is there some way to pass a language to getVoices()
?
HTML
The HTML language of my page is set to US English.
<!DOCTYPE html>
<html lang="en-US">
I have tried lang="en", removing the DOCTYPE declaration, etc. with no change.
Javascript
var _voices = [];
speechSynthesis.onvoiceschanged = listVoices;
function listVoices() {
_voices = speechSynthesis.getVoices();
}
function getDefaultVoice() {
var voice = '';
_voices.some(function(v) {
if (v.default) {
voice = v.name;
return true;
}
});
return voice;
}