0

我试图从 localhost 运行一个 html/javascript 应用程序。该应用程序使用 annyang 语音控制工具,该工具在我的 Win7 PC 上的 Chrome 浏览器中运行良好。

网站上的评论 ( https://www.talater.com/annyang/ ) 建议:-

对于那些想在本地主机上运行它的人-不要使用“lokalhost/index.html”之类的链接。使用 http://127.0.0.1:58604/web/index.html之类的 IP ,chrome 会要求你允许你的麦克风。

我试过http://127.0.0.1/myPage.html加载正常,但 Chrome 不要求麦克风权限或响应语音命令。

使用http://127.0.0.1:58604/myPage.html会出现“网页不可用”错误。

有人对如何使它工作有任何建议吗?(我不能在网站上说话,因为我不做 facebook)。

编辑 1

这是我的 HTML 页面中的相关代码(我已经美化了原始缩小的 annyang.min.js )

<script src="myFiles/js/annyang.js"></script>

function F_Init_Voice_Commands() //... using Annyang
{
    //... annyang object is created in the annyang.js module.
    if ( annyang ) 
    {
        //... Let's define our first command. First the text we expect ('Hello'), and then the function it should call (alert())
         var commands = 
        {
            'Hello': function() 
            {
              alert ("Hello there!");
            }
        };
        //.. Add our commands to annyang object
        annyang.addCommands(commands);

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

编辑 2

使用 URL:localhost/myFile.html 或 URL:127.0.0.1/myFile.html 可以正常工作。但似乎不能有任何其他浏览器选项卡同时使用麦克风访问。

4

1 回答 1

0

可能是 Https 的问题? https://github.com/TalAter/annyang/issues/53

似乎它可能需要 https 才能正常工作。

于 2015-10-25T23:43:00.270 回答