简体   繁体   中英

Issues with Annyang speech recognition

I am currently trying to create my own JARVIS system as a web app. So of course, like any good JARVIS system, it needs good speech recognition. I have done research trying to find a JavaScript speech recognition API that I can customize as much as I like, and have decided to use Annyang. (It's simple, and works well)

I spent some time playing around with it, and just when I thought I had got it working, I ran into a problem. It wasn't working when I tried to view the file locally, so I hosted it on my computer with MAMP to see if it worked. It came up with the dialog saying "localhost would like to access the microphone", but when I clicked allow, it reappeared. It kept reappearing and wouldn't go away until I clicked deny. I was using the following code:

<!DOCTYPE html>

<script src="http://cdnjs.cloudflare.com/ajax/libs/annyang/1.0.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() {
  alert("hello");
}
};

// Initialize annyang with our commands
annyang.init(commands);

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

Which is the demo code they supplied on their website .

If anyone can help me figure out why it is repeatedly asking to use my microphone when I click allow, then thank you in advance!

Cheers, Fjpackard.

https://github.com/TalAter/annyang/issues/53

Please read through the whole issue. You might need to setup HTTPS for it.

The prompt will reappear if there is no SSL for every time the Listening action starts.

If you have a valid SSL on a FQDN it will work, as long as you have setup the javascript correctly.

Right now it is prompting, as after you Allow it, it cycles through the preconfigured matches, and then starts over, and prompts again.

I have a working example in Bulgarian, if you want to look at: https://piperko.com

Even I faced the same situation, I got it resolved. There are 2 solutions to fix the issue.

  1. Close all the other tabs which uses the microphone.
  2. Recheck, in your annyang.js file

     abort: function () { autoRestart = false; if (isInitialized) { recognition.abort(); } } 

    Which, need to remove stop the activities of microphone from all the inactive tabs, and need to activate only for current tab.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM