Do more on the web, with a fast and secure browser!

Download Opera browser with:

  • built-in ad blocker
  • battery saver
  • free VPN
Download Opera

SpeechSynthesis has no voices or errors Opera 28 Android 4.4.2

  • window.speechSynthesis.getVoices().length returns 0

    Opera never triggers onvoiceschanged yet (on windows desktop) the call to speechSynthesis.speak(chat) works and after the voice invocation getVoices() now returns an array of length one. On Android I get no audio and no errors and absolutely no events 😞

    Please help.

    Cheers Richard Maher

    <!DOCTYPE html>
    <script type="text/javascript">
    var voices;
    var done = false;
    function fini()
    }function errorLog()
    function talk()
    if (!('speechSynthesis' in window)) {
    alert("Unsupported browser");
    alert("Count is "+speechSynthesis.getVoices().length);

    try {
        speechSynthesis.onvoiceschanged = function() {
        voices = window.speechSynthesis.getVoices();
        alert("Voices " + voices.length);
        if (!done) theWork();
        voices = speechSynthesis.getVoices();
        if (voices.length != 0) theWork();
    } catch (err) {alert("0");alert(err.description||err.message);}


    function theWork()
    done = true;
    alert("Getting ready." + speechSynthesis.speaking + voices.length);
    var utterance = "Hello World";
    var chat;
    try {
    chat = new SpeechSynthesisUtterance(utterance);
    } catch (err) {alert("1");alert("new error "+ err.description||err.message);}

    try {
    chat.addEventListener('end', fini, false);
    } catch (err) {alert("2");alert("AddEvent "+ err.description||err.message);}
    try {
    chat.addEventListener('error', errorLog, false);
    } catch (err) {alert("3");alert("AddEvent "+ err.description||err.message);}
    try {
    chat.addEventListener('abort', errorLog, false);
    } catch (err) {alert("4");alert("AddEvent "+ err.description||err.message);}
    try {
    } catch (err) {alert("5");alert("Speak "+ err.description||err.message);}


    On Safari this example won't fire any known events

    onend, onerror, even onended: -

    <input type="button" value="Talk" onclick="talk()" />

    No probs on Chrome or Opera. Spewin!

  • Here's the best strategy I can come up with as Opera is small beer and I have to get on to speech Recognition: -

    The first getVoices() tells Opera to swing into action.
    Opera needs you to release the thread so it can get the voices info
    Opera will not honour/deliver the onvoiceschanged event.
    I stick a setTimout(myvoicesHandler,0) in there.
    If the handler gets voices it updates the selections else it stays at zero
    the feature detection has to move way down into the code

    But why are there no voices on Opera 28 Android 4.4.2?