Home » Jquery » javascript – why this Text to speech code does not work in phones

javascript – why this Text to speech code does not work in phones

Posted by: admin February 22, 2020 Leave a comment

Questions:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<Title>Text To Speech</title>
</head>
<body>
```

i dont know what is the problem this code is actually work in website but in the phones does not work i dont know what to do

    <input type="text" name="Text">
    <a href="#" class="say">Say It</a>

    <audio src="" class="speech" hidden></audio>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>


    <script>
    $(function() {
    $('a.say').on('click',function(e){
    e.preventDefault();
    var text= $('input[name="Text"]').val();
    text = encodeURIComponent(text);
    console.log(text);
    var url = "http://translate.google.com/translate_tts?tl=en&q=" + text + "&client=tw-ob";
    $('audio').attr('src', url).get(0).play();
    });
    });
    </script>
    </body>
    </html>
How to&Answer: