语音输出附加两次

时间:2017-06-01 03:59:10

标签: javascript html5 speech-recognition

我想使用原生浏览器语音语音API。但我得到了奇怪的结果。这是我的代码。它使用jquery和

https://sdkcarlos.github.io/sites/artyom.html

 <!DOCTYPE html>
<html lang="en">
    <head>
        <title>Title of the document</title>
        <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
        <script src="/js/jquery-3.2.1.min.js"></script>
        <script src="/js/artyom.min.js"></script>
    </head>

    <body>
        <input type="button" onclick="startRecognition();" value="Recognize text" />
        <input type="button" onclick="stopRecognition();" value="stop recognition" />
        <input type="button" onclick="clearX();" value="clear" />
        <script>

            var buffer = "";

            var settings = {
                continuous:false, // Don't stop never because i have https connection
                onResult:function(text){
                    // text = the recognized text
                    //console.log(text);
                    buffer = text;
                },
                onStart:function(){
                    //console.log("Dictation started by the user");
                },
                onEnd:function() {
                    //alert("Dictation stopped by the user");
                    jQuery("#out").append("<div>" + buffer + "</div>");
                    UserDictation.start();
                }
            };

            var UserDictation = artyom.newDictation(settings);

            function startRecognition(){
                //UserDictation.start();
            }

            function stopRecognition(){
                //UserDictation.stop();
            }

            UserDictation.start();

            function clearX() {
                jQuery("#out").empty();
            }
        </script>
        <div id="out"></div>
    </body>

</html> 

除非我尝试这个,它给出的结果看起来像是重复的作品/短语。就像我说computer一样,它给了我computercomputer。或者,如果我说what's the expected price?,它会给我what'swhat'swhat'sthewhat's the what's the what's the expected what's the expected price, etc...

也有这个页面

https://www.google.com/intl/en/chrome/demos/speech.html

这似乎与我有同样的问题。

但是在另一个网站上还有一个相同js库的演示

https://apps.golightlyplus.com/speech-to-text-demo/

这似乎很好地显示了结果。

有谁知道发生了什么事?

由于

0 个答案:

没有答案