A simple voice command module for MagicMirror² that is highly configurable
Voice Commands is a voice commands module that is designed to be bare bones and allow the user to do whatever they want on their MagicMirror². The voice recognition is built off of annyang so it uses a command based structure. However, it does not use an activation phrase and instead just opts for direct use of statements.
annyang does not work when Magic Mirror is run using some browsers. In order to ensure that it works, use chrome or firefox if possible. This also means that electron cannot be used since it is a chromium wrapper. The serveronly mode must be used for this module to function.
Navigate to the modules folder of your Magic Mirror installation.
cd ~/MagicMirror/modules
Clone the repository.
git clone https://github.com/Veldrovive/MMM-Voice-Commands.git
Navigate into the installation and Install Dependencies.
cd MMM-Voice-Commands && npm i
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", "2");
}
}
}
},
...
]
this
refers to the module’s this
.For more information on the command stucure look to the annyang documentation
"switch to (the) :page (page)": "PAGE_SELECT"
or "go to (page) :number": "PAGE_SELECT"