Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with Annyang speech recognition

I am currently trying to create my own J.A.R.V.I.S system as a web app. So of course, like any good J.A.R.V.I.S 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.

like image 893
fpackard Avatar asked Dec 23 '13 11:12

fpackard


2 Answers

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

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

like image 154
leorex Avatar answered Nov 14 '22 23:11

leorex


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.

like image 39
Raja Mouli Ankireddy Avatar answered Nov 14 '22 22:11

Raja Mouli Ankireddy