MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. jeremytripp
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 14
    • Groups 0

    Posts

    Recent Best Controversial
    • Voice Controlled Wake/Sleep Function

      So after setting up the Snowboy Voice Control module, the camera module, and the motion detector module (all working perfectly), I got a little ambitious. I trained a model for the keywords “Wake Up” and “Go to sleep”, added the keywords to voicecontrol.js, then expanded the node_helper.js file inside the Motion Detector module to act when the WAKE_UP and GO_TO_SLEEP notifications are broadcast, but it’s not working and I’m not sure why. Could use a little help – what have I missed?

      My understanding is that voicecontrol.js registers the keywords, Snowboy detects them using the .pmdls in the MM root, then broadcasts the notification to all existing modules, which is why I decided to append to the end of the motion detector module since the action is inherently the same (switch off the monitor, switch on the monitor, given some conditional element) rather than building a separate module.

      Only supplying the pertinent code blocks here for brevity as the rest seems to be working, but can supply all if it will help.

      voicecontrol.js (defines the keyword, their broadcast notification, and front end elements)

      models: [
                          {
                              keyword: "Show Camera",
                              description: "Say 'Show Camera' to display camera",
                              file: "showCamera.pmdl",
                              message: "SHOW_CAMERA"
                          },
                          {
                              keyword: "Hide Camera",
                              description: "Say 'Hide Camera' to hide camera",
                              file: "hideCamera.pmdl",
                              message: "HIDE_CAMERA"
                          },
                          {
                              keyword: "Selfie",
                              description: "Say 'Selfie' when camera is visible",
                              file: "selfie.pmdl",
                              message: "SELFIE"
                          },
                          {
                              keyword: "Wake Up",
                              description: "Say 'Wake Up' to turn on the mirror",
                              file: "wakeUp.pmdl",
                              message: "WAKE_UP"
                          },
                          {
                              keyword: "Go To Sleep",
                              description: "Say 'Go To Sleep' to turn off the mirror",
                              file: "goToSleep.pmdl",
                              message: "GO_TO_SLEEP"
                          },
                      ]
      

      motion detector node_helper.js (catches the notification, supposed to execute the monitor on/off action)

      // Subclass socketNotificationReceived received.
        socketNotificationReceived: function (notification, payload) {
            const self = this;
            if (notification ===  'MOTION_DETECTED' && this.started == false) {
                const self = this;
                this.started = true;
                this.activateMonitor();
            }
       
            if (notification ===  'WAKE_UP' && this.started == false) {
                const self = this;
                this.started = true;
                this.activateMonitor();
            }
       
            if (notification ===  'DEACTIVATE_MONITOR' && this.started == false) {
                const self = this;
                this.started = true;
                this.deactivateMonitor();
            }
       
            if (notification ===  'GO_TO_SLEEP' && this.started == false) {
                const self = this;
                this.started = true;
                this.deactivateMonitor();
            }
        }
      

      NOTE: Originally, I set it up like below to be more concise, but after running npm start on the mirror, it would load up momentarily, then shut down the monitor almost immediately (without any interaction whatsoever) and no keyboard command or voice command would bring it back up (had to unplug and reboot to bring it back). Therefore, I opted for separate conditional statements as above – which doesn’t deactivate the monitor immediately, but also doesn’t work given the voice prompt, soooooooo…:

      // Subclass socketNotificationReceived received.
        socketNotificationReceived: function (notification, payload) {
            const self = this;
            if (notification ===  'MOTION_DETECTED' && this.started == false ||
                                  'WAKE_UP && this.started == false) {
                const self = this;
                this.started = true;
                this.activateMonitor();
            }
       
            if (notification ===  'DEACTIVATE_MONITOR' && this.started == false
                                  'GO_TO_SLEEP' && this.started == false) {
                const self = this;
                this.started = true;
                this.deactivateMonitor();
            }
         }
      

      Any guidance in my logic would be appreciated! Thanks!

      posted in Troubleshooting voice control motion module troubleshoot
      J
      jeremytripp
    • RE: Camera module

      Follow up: I tried both configurations and it only works when all voice command keywords are in voicecontrol.js, so that answers my question, I suppose!

      posted in Utilities
      J
      jeremytripp
    • RE: Camera module

      Tested the voice control + camera module today and got both working. Thanks @James for the tip on the missing config curly brackets. Was starting to drive me crazy as no JS Linters were picking it up.

      For future reference, the voice control module now comes pre-packaged with the three camera commands by default in the voicecontrol.js file, so in your config.js file, you only need to add:

      {
          module: 'voicecontrol',
          position: 'bottom_left'			
      },
      

      In fact, if you do add the config: definitions and any keywords to your config.js file, it actually overrides the three default camera commands. With that said, is it best practice to add additional keyword commands to voicecontrol.js OR to remove the defaults from voicecontrol.js and place everything in config.js?

      I also get the ALSA lib error messages in Terminal after quitting the mirror, as well as the countdown bug James mentions after taking a picture, but everything seems to work and I DID receive the email no problem (using Gmail, after following @alexyak’s instructions on “Allowing Less Secure Apps” and “Allowing Access To Your Gmail Account”).

      All in all, awesome work, Alex! Thrilled to now have 3 of your modules running on my mirror as I’m running motion sensor too!

      posted in Utilities
      J
      jeremytripp
    • Voice Control Audio Quality

      Hello all, I’m about to tackle @alexyak’s Voice Control module and wondering if audio quality has been a concern for others who’ve used any of the voice recognition modules? Right now I’m using a USB HD webcam to capture audio and the quality is less than ideal when recording playback (but probably usable). Just wondering if I need to go through the whole ordeal of getting a sound card and all that before I bother training models on Snowboy. Thanks in advance!

      posted in Troubleshooting
      J
      jeremytripp
    • 1 / 1