Open Bug 1895109 Opened 5 months ago Updated 3 months ago

Text-to-Speech (TTS) uses wrong voice on first playback

Categories

(Core :: Web Speech, defect)

Firefox 126
defect

Tracking

()

People

(Reporter: justdave, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0

Steps to reproduce:

  1. Write javascript code on your website that uses the built-in text-to-speech (TTS) to speak some text.
  2. Pick specific voices to use on Mac and Windows, and ask it to use whichever of those you find first.

Minimized testcase code is as follows:

        const synth = window.speechSynthesis;
        const voices = synth.getVoices();
        let text = "This is something witty for you to hear.";
        const utterThis = new SpeechSynthesisUtterance(text);
        for (const voice of voices) {
            if ((voice.name == 'Daniel') || (voice.name == 'Microsoft David - English (United States)')) {
                utterThis.voice = voice;
            }
        }
        utterThis.pitch = 1;
        utterThis.rate = 0.9;
        synth.speak(utterThis);

An HTML page containing a button to press to test this can be found at https://www.justdave.net/grab/tts_testcase.html

Actual results:

On both Windows and Mac, the text is spoken using the default voice the first time you trigger it, not the voice you actually asked it to use. Subsequent playback attempts will use the requested voice. It only uses the wrong one the first time. It only fails the very first time, even after reloading the page it will be correct, until you restart the browser.

Expected results:

The text should be spoken using the chosen voice the first time.

The Windows machine where I reproduced this is running Firefox 125.0.3 release version.

Further testing indicates you don't need a browser restart, you just have to open a new tab with that URL again. The persistence seems to be tied to the tab it was in.

I've also removed the pitch and rate settings (further minimizing it) and it's still reproducible.

Component: Untriaged → Web Speech
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.