Text to speech in HTML5 ,JavaScript which runs on

2020-06-21 05:01发布

I have created one sample example for Text to speech in HTML5 using JavaScript which runs on only Chrome, but when I am trying to run it on other browser i.e. IE, Mozilla, Safari nothing will happed. What should I do to run my Text To speech demo code on all browser.

<code>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
    <script>
        $(document).ready(function () {
            $("#startBtn").on('click', function (e) {
                debugger;
                var u1 = new SpeechSynthesisUtterance('Hello Word..');
                u1.lang = 'en-US';
                u1.pitch = 1;
                u1.rate = 1;
                //u1.voice = voices[10];
                u1.voiceURI = 'native';
                u1.volume = 1;
                speechSynthesis.speak(u1);

            });
        });
    </script>
    <title> </title>
</head>
<body>
    <input type="button" id="startBtn" value="Hello Word.." />
</body>
</html>

</code>

0条回答
登录 后发表回答