sdkcarlos / artyom.js

A voice control - voice commands - speech recognition and speech synthesis javascript library. Create your own siri,google now or cortana with Google Chrome within your website.
http://sdkcarlos.github.io/sites/artyom.html
MIT License
1.23k stars 370 forks source link

Sometimes it breaks? Continuous mode doesn't work? #59

Open baptisteArno opened 6 years ago

baptisteArno commented 6 years ago

Hello,

I need my assistant to constantly listen for mic input. But sometimes it just stop listenning (when looking at debug, it doesn't print anything). If I understood well, continuous mode is suppose to restart the "object" right? How can I make sure it doesn't crash?

// Create a variable that stores your instance
    this.artyom = new Artyom();
    // Start the commands !
    this.artyom.initialize({
      lang: 'fr-FR',
      continuous: true, // Listen forever
      soundex: true, // Use the soundex algorithm to increase accuracy
      listen: true,
      debug: true,
      name: 'Watson',
    }).then(() => {
      console.log('Artyom has been succesfully initialized');
    }).catch((err) => {
      console.error(`Artyom couldn't be initialized: , ${err}`);
    });

    this.artyom.on(['*'], true).then((_, wildcard) => {
      this.listenForCommand(wildcard);
    });

    this.artyom.when('SPEECH_SYNTHESIS_START', () => {
      if (this.artyom.isRecognizing()) {
        this.artyom.dontObey();
      }
    });

    this.artyom.when('SPEECH_SYNTHESIS_END', () => {
      if (!this.artyom.isRecognizing() || !this.artyom.isSpeaking()) {
        this.artyom.obey();
      }
    });
listenForCommand(wildcard) {
    this.bip.play();
    this.artyom.say(wildcard);
  }
vesper8 commented 6 years ago

I'm experiencing the same thing and have not found a way to reproduce it reliably or debug it at all.. if you find out what's happening or have any insight at all.. such as a way to replicate please reply back because I really need to find a way to fix this too.

I wonder if a timeout that reinitializes it every minute would be a workaround

baptisteArno commented 6 years ago

I found out how to "reproduce" this problem. It's basically because of the noise. When I use a good mic it works undefinetly as long as I speak clearly. But whenever I speak non words such as 'Aaaaaaaaaa' and noises like these. it crashes. I'll try to find what's happening. I'll let you know..

zen85 commented 5 years ago

any progress on that? i experience this also just with podcasts in the background or people talking. after some time it restarts and works as expected again but does not print out anything. i simply can not nail the problem down...