Deniz Turna
Deniz Turna

Reputation: 31

Text To Speech API on iOS

For the following code, it does not work on iOS Safari (iPad Air 2). It works everywhere else (Safari on Mac, Chrome on windows)

When I tried to debug the script below on the iPad's Safari (connected to Mac), it does not give any error. It is just silent. No speech.

Please not that this is the simple script, I created many others, such as setting up the voice etc.Nothing works..There is also a separate problem getting the voices, but I want to see if it works with the default voice first.

P.S. If I do XCode programming, using swift to develop native code on iPad (not in Safari), speech works on the iPad, but my goal is to create a web page using the Speech API


<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <script>
        function Speak() {
            speechSynthesis.speak(new SpeechSynthesisUtterance("Hello, this is my voice on a webpage"));

            var speech = new SpeechSynthesisUtterance();
            speech.text = "Hello";
            speech.volume = 1; // 0 to 1
            speech.rate = 1; // 0.1 to 9
            speech.pitch = 1; // 0 to 2, 1=normal
            speech.lang = "en-US";
            speechSynthesis.speak(speech);
        }
    </script>
    <a  onclick="Speak()">ClickMe</a>
</body>
</html>

Upvotes: 3

Views: 1802

Answers (1)

Simon_Weaver
Simon_Weaver

Reputation: 146160

Check your volume, mute switch and make sure you don't have bluetooth headphones set up. It must also be within a click event (which you are doing). Try a normal video to make sure you get sound.

What made it work for me?

  • I went downstairs
  • I watched a video in Safari
  • I tried again and it worked
  • I then tried again and it worked
  • I tried again and it didn't work
  • I played a video again
  • It still didn't work
  • I force quit EVERYTHING
  • It then worked
  • And then it didn't
  • Then I realized I hadn't closed browser tabs
  • Then it worked

I think there's a bug (iOS11)

Upvotes: 3

Related Questions