Web Speech API text-to-speech not working on mobile

Viewed 2791

The below works on Desktop Chrome/Safari/Firefox, but not on mobile.

Even though on Chrome mobile I have 1) SpeechRecognition working perfectly; 2) SpeechSynthesisUtterance loads correctly, I can check all the attributes, load voices (remote debugging via DevTools) - just the phone wouldn't speak (iPhone Safari and Android Chrome tested).

Also, when I try this demo on mobile, it says my browser supports speech synthesis, I can select from the voices available, but the browser won't speak.

Any ideas what might be going wrong here?

<script>
    var u = new SpeechSynthesisUtterance();
    u.text = "hello world";
    speechSynthesis.speak(u);
</script>
3 Answers

Have you tried adding window in front of speechSynthesis? The code is window.speechSynthesis.speak(u) .

Android Chrome :

I opened my " so nice, wonderful and fantastic Html page with java script " and I discovered nothing works on my mobile phone... (Android)

1.) I googled and found https://support.google.com/accessibility/android/answer/6006983?hl=en

Text-to-speech output To specify text-to-speech settings for your device: Open your device's Settings app . Select Accessibility, then Text-to-speech output. Choose your preferred engine, language, speech rate, and pitch. Note: The default text-to-speech engine choices vary by device. Options can include Google's Text-to-speech engine, the device manufacturer's engine, and any third-party text-to-speech engines that you've downloaded from the Google Play Store. Optional: To hear a short demonstration of speech synthesis, press Play. Optional: To install voice data for another language, select Settings , then Install voice data. Choose the language that you want to install.

Note : (Select Accessibility, then Text-to-speech output.)

I activated "touch to hear", as my options were filled with whatever, but not the above mentioned. The "TalkBack" instead was a little too heavy, so I left it "unused /unselected " ...

2.) speechSynthesis.resume() and speechSynthesis.pause(); do not work, no other solution for now, than excluding them if mobile browser / touch device is detected.

Related