Sarah Elan
Sarah Elan

Reputation: 2461

Is Chrome OS German the correct default voice on Chrome OS?

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;
    }

Upvotes: 2

Views: 658

Answers (1)

James Milner
James Milner

Reputation: 899

I figured this out. My default was set to German. This guide from Treehouse explains the process:

http://blog.teamtreehouse.com/getting-started-speech-synthesis-api

Explicitly you do something like this:

var utterance = new SpeechSynthesisUtterance('Hello Treehouse');
var voices = window.speechSynthesis.getVoices();

utterance.voice = voices.filter(function(voice) { return voice.lang == 'en-GB'; })[0];

window.speechSynthesis(utterance);

Then just change the language to be whichever you need (i.e. American english etc). You get the list from the voices variable listed above and can explore in your developer tools.

Upvotes: 0

Related Questions