Veldrovive/MMM-Voice-Commands

Help with setup

Closed this issue · 13 comments

Hi, I am having trouble with setting up mmm-Voice-Controls.

I am wanting the be able to change pages (mmm-Page-Selector).
Can you please have a look at my setup and let me know where I am going wrong?

{
    module: "MMM-Voice-Commands",
    config: {
        debug: true, //Displays end results and errors from annyang in the Log
        autoStart: true, //Adds annyang commands when it first starts
        activateCommand: "hello mirror", //Command to active all other commands
        deactivateCommand: "goodbye mirror", //Command to deactivate all other commands
        alertHeard: true, //Whether an alert should be shown when annyang hears a phrase (mostly for debug)
        commands: {
            "command statement :variable (optional statement)": "SOCKET_NOTIFICATION_NAME",
            //The payload of the socket notification will be whatever is said in the :variable
            "command statement *variable": function(param){
                alert("Whatever is said in the *variable space is given as the "+param);
                //These function's 'this' are bound to the module's 'this' so you can do stuff like:
                this.sendNotification ("PAGE_SELECT", "1");
                this.sendNotification ("PAGE_SELECT", "2");
                "go to (page) :number": "PAGE_SELECT"
            }
        }
    }
},
    {
        "module": "MMM-Page-Selector",
        "position": "top_bar",
        "config": {
            "defaultPage": "2",
            "displayTitle": true
        }
    },
    {
        "module": 'MMM-Cursor',
        "config": {
            // See 'Configuration options' for more information.
        }
    },
    {
        "module": "alert",
        "pages": "all"
    },
    {
        "module": "MMM-page-indicator",
        "pages": {"all": "bottom_bar"},
    },

Thank you

Nothing jumps out to me as incorrect in your config. Make sure that you are in serveronly mode and not running Magic Mirror directly through electron.
The first thing to check is if there are any errors in the log. If you enter inspect element, they should be in the console.
Then I would check if the mic is being registered by your browser. You can simply look up Microphone Test or something similar.
Finally, I would make sure that you are allowing use of the microphone. If you click to the left of the url, you should be able to see security options which include use of the microphone.

Sorry I should have mentioned that this is running on a Raspberry PI and is not running through the Browser.

The Microphone does work with the Pi as I have tested this. I have debugging enabled but I don't see where the Log files are. (Sorry kinda new). Shouldn't they be in /Var/Log ?

Ah, I see there is a bit of confusion. When you run Magic Mirror, it launches a chromium window using a javascript library called Electron. The problem is, this module uses voice recognition capabilities that are not included in chromium so chrome or firefox must be used. This means that magic mirror cannot be started with a simple npm start and you must instead use node serveronly to start it in serveronly mode then navigate to the supplied url using one of the above web browsers.

Debug is handled by the browser so you can access it by opening developer tools then looking at the console window. You can find out how to open developer tools by simply looking up "How to open developer tools on your browser".

Hello, I did not understand how used node serveronly, when I type this in LXTerminal I get this:

module.js: 550
throw err;
^
Error: Can not find module '/ home / pi / serveronly'
at Function.Module._resolveFilename (module.js: 548: 15)
at Function.Module._load (module.js: 475: 25)
at Function.Module.runMain (module.js: 694: 10)
at startup (bootstrap_node.js: 204: 16)
at bootstrap_node.js: 625: 3

I am a beginner in this environment, how to do it?
Thank you.

Hello, I did not understand how used node serveronly, when I type this in LXTerminal I get this:

module.js: 550
throw err;
^
Error: Can not find module '/ home / pi / serveronly'
at Function.Module._resolveFilename (module.js: 548: 15)
at Function.Module._load (module.js: 475: 25)
at Function.Module.runMain (module.js: 694: 10)
at startup (bootstrap_node.js: 204: 16)
at bootstrap_node.js: 625: 3

I am a beginner in this environment, how to do it?
Thank you.

Just run node serveronly from the MagicMirror folder.

Ah, I see there is a bit of confusion. When you run Magic Mirror, it launches a chromium window using a javascript library called Electron. The problem is, this module uses voice recognition capabilities that are not included in chromium so chrome or firefox must be used. This means that magic mirror cannot be started with a simple npm start and you must instead use node serveronly to start it in serveronly mode then navigate to the supplied url using one of the above web browsers.

Debug is handled by the browser so you can access it by opening developer tools then looking at the console window. You can find out how to open developer tools by simply looking up "How to open developer tools on your browser".

Thanks @Veldrovive for clarifying this.

I have enabled the Microphone now within the browser and running in servermode

My issue is that if I run the code above that I get a lot of errors when I check the config.js file.
I am not sure if I have entered the details correctly.

The issue is around the "go to (page) :number": "PAGE_SELECT" line.
If I remove I don't get any errors.
It is not sending the notification to 'mmm-page_selector' to change the page when 'Go to page one' is spoken. It shows the notification after 'Hello mirror' is spoken and recognises what I say.

Any ideas?

@fUze-twyci Yep. I'm assuming you have your magic mirror installed in your /home/pi directory. In that case, you would just use cd MagicMirror in order to navigate into your Magic Mirror folder in which there is a serveronly file that you can run using node serveronly on the terminal like you did.

Ok thanks you 👍

I'm not quite sure @PaulSan1234.

Are you saying that magic mirror tells you that you have an invalid config.js when you start it?
If that is the case, you should check that every line has a comma after it. You can check if the JSON is valid by putting it into one of the multitudes of online JSON parsers.

If the errors are on the client-side, then I would need to see the errors to know what the issue is.

@Veldrovive When I check the config.js file with "go to (page) :number": "PAGE_SELECT", included (See Below)

var config = {
"address": "0.0.0.0",
"port": 8080,
"ipWhitelist": [],
"language": "en",
"timeFormat": 24,
"units": "metric",
"modules": [
    {
    module: "MMM-Voice-Commands",
    config: {
        debug: false, //Displays end results and errors from annyang in the Log
        autoStart: true, //Adds annyang commands when it first starts
        activateCommand: "hello mirror", //Command to active all other commands
        deactivateCommand: "goodbye mirror", //Command to deactivate all other commands
        alertHeard: false, //Whether an alert should be shown when annyang hears a phrase (mostly for debug)
        commands: {
            "command statement :variable (optional statement)": "SOCKET_NOTIFICATION_NAME",
            //The payload of the socket notification will be whatever is said in the :variable
            "command statement *variable": function(param){
                alert("Whatever is said in the *variable space is given as the "+param);
                //These function's 'this' are bound to the module's 'this' so you can do stuff like:
                this.sendNotification ("PAGE_SELECT", "Dashboard");
                this.sendNotification ("PAGE_SELECT", "Calendar");
                "go to (page) :number": "PAGE_SELECT",
                }
        }
    }
},

I get this error from when I check the config.js file.

pi@raspberrypi:~/MagicMirror $ npm run config:check

magicmirror@2.7.1 config:check /home/pi/MagicMirror
node tests/configs/check_config.js

Checking file... /home/pi/MagicMirror/config/config.js
Line 27 col 21 Expected an assignment or function call and instead saw an expression.
Line 27 col 43 Missing semicolon.
Line 27 col 43 Expected '}' to match '{' from line 22 and instead saw ':'.
Line 27 col 45 Expected '}' to match '{' from line 19 and instead saw 'PAGE_SELECT'.
Line 30 col 9 Expected ']' to match '[' from line 10 and instead saw '}'.
Line 31 col 6 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Line 33 col 23 Expected an identifier and instead saw 'MMM-Page-Selector'.
Line 34 col 25 Expected an identifier and instead saw 'top_bar'.
Line 36 col 32 Expected an identifier and instead saw 'Calendar'.
Line 37 col 33 Expected an identifier and instead saw 'true' (a reserved word).
Line 39 col 10 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Line 41 col 23 Expected an identifier and instead saw 'MMM-Cursor'.
Line 42 col 23 Empty destructuring.
Line 45 col 10 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Line 47 col 23 Expected an identifier and instead saw 'alert'.
Line 48 col 22 Expected an identifier and instead saw 'all'.
Line 49 col 10 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Line 51 col 23 Expected an identifier and instead saw 'MMM-page-indicator'.
Line 52 col 30 Expected an identifier and instead saw 'bottom_bar'.
Line 53 col 10 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Line 55 col 23 Expected an identifier and instead saw 'clock'.
Line 56 col 36 Expected an identifier and instead saw 'top_left'.
Line 56 col 60 Expected an identifier and instead saw 'top_left'.

But, if I dont include the "go to (page) :number": "PAGE_SELECT", then I don't get any errors.

I just want to know the method of how MMM-Voice-Commands communicates with MMM-Page-Selector.

Where I am at with this is, I can confirm that MMM-Voice-Command does acknowledge my voice through using servermode and the web browser.

@Veldrovive any advice on the issues?

Sorry, I went back to uni and forgot all about this. I don't know how I missed this before, but it looks to me like you have your "go to (page) :number": "PAGE_SELECT", inside the javascript function which is indeed invalid syntax.
A corrected file would look like this:

var config = {
"address": "0.0.0.0",
"port": 8080,
"ipWhitelist": [],
"language": "en",
"timeFormat": 24,
"units": "metric",
"modules": [
    {
    module: "MMM-Voice-Commands",
    config: {
        debug: false, //Displays end results and errors from annyang in the Log
        autoStart: true, //Adds annyang commands when it first starts
        activateCommand: "hello mirror", //Command to active all other commands
        deactivateCommand: "goodbye mirror", //Command to deactivate all other commands
        alertHeard: false, //Whether an alert should be shown when annyang hears a phrase (mostly for debug)
        commands: {
            "command statement :variable (optional statement)": "SOCKET_NOTIFICATION_NAME",
            //The payload of the socket notification will be whatever is said in the :variable
            "command statement *variable": function(param){
                alert("Whatever is said in the *variable space is given as the "+param);
                //These function's 'this' are bound to the module's 'this' so you can do stuff like:
                this.sendNotification ("PAGE_SELECT", "Dashboard");
                this.sendNotification ("PAGE_SELECT", "Calendar");
          }
          "go to (page) :number": "PAGE_SELECT",
        }
    }
},

Although this still leaves the example code in so I would suggest something like this:

var config = {
"address": "0.0.0.0",
"port": 8080,
"ipWhitelist": [],
"language": "en",
"timeFormat": 24,
"units": "metric",
"modules": [
    {
    module: "MMM-Voice-Commands",
    config: {
        activateCommand: "hello mirror", //Command to active all other commands
        deactivateCommand: "goodbye mirror", //Command to deactivate all other commands
        commands: {
            "go to (page) :number": "PAGE_SELECT",
        }
    }
},

I'll assume this has been fixed.