VoiceControl module


  • Module Developer

    I’ve managed to create the VoiceControl module based on Snowboy Hotword detection: https://snowboy.kitt.ai/

    https://github.com/alexyak/voicecontrol



  • @alexyak cool! How does it work?


  • Module Developer

    Pull it or clone from the github into your MM modules directory. Go to the https://snowboy.kitt.ai, login with any of your emails, create voice models as much as you need and copy the pmdl files into the root folder, modify the config.js as it described in the Readme.md.



  • where to place “notificationReceived: function” to get a text output on the mirror?


  • Module Developer

    @tyho said in VoiceControl module:

    notificationReceived

    You can put it in any other module that you would like to react on the voice command and then just call self.updateDom(self.config.animationSpeed);



  • Wow! @alexyak nice work. I got it running. and i am playing around with it.

    1 question:
    I want to display the commands i said for 3 seconds.

    If i say a command i can get the text with:
    this.config.text = “going to sleep…”;
    this.updateDom(this.config.animationSpeed);

    Is there a way to auto reset it to default/hide after a few seconds? (i am trying this for hours already ^^)


  • Module Developer

    @tyho, you can use setTimeout function to wait a for few seconds and then reset the text value. Something like that:

    var self = this;
    setTimeout(function(){
    self.config.text = “”;
    self.updateDom …
    }, 3000);



  • thanks again it’s working :)

    i made a notification.js:

    notificationReceived: function(notification, payload, sender) {
    		var self = this;
    				if (notification === "go_to_sleep"){
                		this.config.text = "going to sleep...";
    					this.updateDom(this.config.animationSpeed);
    					setTimeout(function(){
    						self.config.text = "";
    						self.updateDom(self.config.animationSpeed);
    					}, 3000);
            		}
    				if (notification === "wake_up"){
                		this.config.text = "waking up...";
    					this.updateDom(this.config.animationSpeed);
    					setTimeout(function(){
    						self.config.text = "";
    						self.updateDom(self.config.animationSpeed);
    					}, 3000);
            		}
        },
    
    

    i have made a node_helper.js:

    const NodeHelper = require('node_helper');
    const exec = require('child_process').exec;
    
    module.exports = NodeHelper.create({
      start: function () {
    	      this.started = false
      }, 
     
      socketNotificationReceived: function(notification, payload) {
        if (notification === 'go_to_sleep' && this.started == false) {
                exec("/opt/vc/bin/tvservice -o", null);
    	}
    	    if (notification === 'wake_up' && this.started == false) {
                exec("/opt/vc/bin/tvservice -p", null);
    	}
      }
    }); 
    

    It shows the command i speak for 3 seconds. But i can’t get the node helper working to actualy turn on and off my monitor. How can i bind this 2 modules? Or do i have to include it as a separate js file?



  • @tyho try this.sendSocketNotification('go_to_sleep', {}); in notification.js otherwise the node_helper doesnt’t get any msg and will not perform any action



  • Great! it’s working! thanks!


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.