4

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>
M3RS
  • 6,720
  • 6
  • 37
  • 47

4 Answers4

2

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Hopefully we can get the .pause() and .resume() functions to work again, this is what breaks the 15 second workaround currently. – Zaffer May 03 '23 at 09:28
1

Sounds like it may be related to: SpeechSynthesisUtterance not working in mobile broswer. It seems that, on mobile browsers, the speech must be initiated by a user interaction at least once, in order to be subsequently initiated programmatically from JavaScript.

k2m5t2
  • 11
  • 2
0

In a related problem, the following code speaks in Chrome Android, but the event listener doesn't seem to be calling the NextWord function while it works fine on Chrome and Safari on macOS:

speechTextString = "Hello World"
speechText = new SpeechSynthesisUtterance( speechTextString );
    speechText.onboundary = function (event)  {
    if ( event.name == "word" ) { NextWord( event.charIndex ) }
    };
JefferyD
  • 23
  • 3
0

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