我的annyang程序出错了

时间:2014-05-26 13:15:59

标签: javascript speech-recognition

我正在尝试实现这个annyang程序:

<script src="//cdnjs.cloudflare.com/ajax/libs/annyang/1.1.0/annyang.min.js"></script>
<script>
    if (annyang) {
        // Let's define our first command. First the text we expect, and then the function it   should call
        var commands = {
            'show tps report': function() {
                $('#tpsreport').animate({bottom: '-100px'});
            }
        };

        // Add our commands to annyang
        annyang.addCommands(commands);

        // Start listening. You can call this here, or attach this call to an event, button, etc.
        annyang.start();
    }

    else{
        alert("Error alert");
    }
 </script>

问题在于我得到了错误警告&#34;消息,我没有弄清楚原因?

1 个答案:

答案 0 :(得分:3)

SpeechRecognition无法在Firefox(桌面版29)中使用,请参阅:

(function () {
    var b = this;
    console.log(b.SpeechRecognition); // undefined
    console.log(b.webkitSpeechRecognition); // undefined
    console.log(b.mozSpeechRecognition); // undefined
    console.log(b.msSpeechRecognition); // undefined
    console.log(b.oSpeechRecognition); // undefined
}).call(this);

https://www.talater.com/annyang/(固定页脚),显示:

fixed footer

SpeechRecognition需要“Google Chrome”等浏览器