Veldrovive/MMM-Voice-Commands

How does this module work?

Closed this issue · 6 comments

Hi,

thanks for making these amazing modules. I am working on a Pi-zero (therefore using node serveronly) and would like to create pages using MMM-Page-Selector and select/switch between them using MMM-Voice-Commands.

I first installed MMM-Page-Selector following the instructions here. Although I did:

  1. git clone https://github.com/Veldrovive/MMM-Page-Selector.git
  2. cd MMM-Page-Selector
  3. npm install (was I not supposed to do this?)

Configuration:

{
			module: "MMM-Page-Selector",
			position: "top_center",
			config: {
			    defaultPage: "main",
			    displayTitle: true,
			    selectPageNotif: ["SELECT_PAGE"],
			    incrementPageNotif: ["PAGE_UP"],
			    decrementPageNotif: ["PAGE_DOWN"],
			    autoChange: {
				interval: 100
			    }
			}
}

This seems to work fine.

Next I tried to install MMM-Voice-Commands. I first tested the mic using arecord and aplay. Then, I did the following, although I wasn't sure if I had to do all the steps:

  1. git clone https://github.com/Veldrovive/MMM-Voice-Commands.git
  2. cd MMM-Page-Selector && npm i (probably not necessary anymore since I already did npm install, while installing MMM-Page-Selector)
  3. cd MMM-Voice-Commands && npm install (wasn't sure if this was required, but I did it anyway)

Configuration:

		{
			"module": "MMM-Voice-Commands",
			"pages": "all",
			"config": {
				debug: true,
				autoStart: true,
				//activateCommand: "hello mirror", //Command to active all other commands
				//deactivateCommand: "bye mirror", //Command to deactivate all other commands
				alertHeard: true, //Whether an alert should be shown when annyang hears a phrase (mostly for debug)
				commands: {
					//"Play video": "ROSS_PLAY_VIDEO",
					//"Pause video": "ROSS_PAUSE_VIDEO",
					//"Show picture": "ROSS_SHOW_IMAGE",
					//"Unpause video": "ROSS_UNPAUSE_VIDEO",
					//"New Picture": "ROSS_NEW_IMAGE",
					"switch to (the) :page (page)": "PAGE_SELECT",
					"go to (page) :number": "PAGE_SELECT",
					"test": function(){
						alert("Heard");
					}
				}
			}
		}

Nothing seems to happen. I started up MM with node serveronly, then tried:

  • "Hello Mirror"
  • "test"
  • "switch to main"
  • "go to page 2".

There is no response whatsoever from the MM / MMM-Voice-Commands on the screen (not even for the voice-command "test").

Please help.
Thanks!

Ah, this has brought up an interesting issue... that you are not running into, but is something that is of importance to me. First, let's figure out what is happening to you.
I tested the module with your config and it seemed to work correctly. Setting alertHeard to true means that whenever annyang detects something, magic mirror will display it on screen. Therefore, I know that this module does not have access to your microphone. By default, magic mirror runs using an http server so browsers may automatically block the microphone. If you are using chrome, this may help. You could also try following these instructions here that explain how to set up an https server for MM. If you are certain that Voice-Commands has access to the microphone, I can dig a little bit deeper to see if there is a problem with pi-zero.
You are going to run into a problem with your use of MMM-Page-Selector. The use of pages: "All" has been replaced with pages: {"all": "POSITION_STRING"} due to changes with how the module handles modules that are always shown.
I haven't used a pi-zero for magic mirror in the past, but I am curious if these modules can every run without maxing out cpu usage. Do they run well?

For the sake of clarity, I am also going to outline the problem that I mentioned at the beginning of my last comment. When MMM-Page-Selector overwrites the config.js, it seems to skip any functions which means that when used in conjuction with MMM-Voice-Commands, none of the commands can be functions or all modules must have a position prop. This will most likely not effect you, but it may be very confusing to other users of MMM-Page-Selectors.

You hit it the nail on its head and it is almost functional on my pi-zero. Let me try to respond to all your suggestions and questions:

  • Indeed since by default MM runs on http, chrome was blocking the mic. I followed your instructions to switch the MM server to https following this, then I started chrome and "allowed" the mic. Now both MMM-Page-Selector and MMM-Voice-Commands are working beautifully well together. Amazing! (So there is still a minor problem with the https certificate and I have to manually accept to browse an unsafe MM page everytime I relaunch MM, but the mic and page-switching are working like a charm).
  • I don't seem to face any problems with my MMM-Page-Selector configuration: pages: "all" instead of pages: {"all": "POSITION_STRING"}. Actually I picked the config from your suggestion here.
  • Runs pretty well on my pi-zero with Raspbian Stretch. Immediately after the startup of the MM it may be a bit jittery (CPU overload), but once loaded, works smoothly. Not tested yet for long hours. (I am thinking of switching off autoStart in MMM-Voice-Commands by default).

Btw, I have not downloaded your latest checkin, I thought I saw an update from you.

So technically that solves my issue. Huge thanks for your help and these modules!

However, I am unable to create a certificate for the https MM server that chrome will accept. I should perhaps follow that up in the appropriate stack-overflow thread? However, since that stack-overflow thread has nothing to do with MM and this module, should I start a new issue here?

Thanks

PS:
--Edit --
I solved the https certificate issue by restarting chrome in non-incognito mode and accepting the certificate and allowing the mic. Incognito mode never remembers the mic (accept) option, and I have to re-accept the mic every time.

To clarify about the ssl certificate, chrome will not trust a self signed certificate by default. To actually get a valid certificate, you would have to go through a Certificate Authority. However, as you discovered, you can simply add your key to the trusted certificates list and then it will be allowed in the future as well.
As for the microphone, I don't run my Magic Mirror in incognito mode so I have never run into this problem. I dont know of any way to allow web pages to access the mic be default in chrome and every new incognito window has its own settings so closing it necessitates allowing the mic access again. I've looked around for a fix, but I couldn't find anything that would be able to save the microphone settings in an incognito window. The work done in this thread was the closest I found, but I couldn't get it to work.

Yes, right you are. I am now running chrome in non-incognito mode with the self signed certificate. All works fine. But remote control fails to load on my Android browser, since apparently chrome there will not even load a page if the certificate is suspicious.

Many thanks again. I think this issue is now closed.

Ok, sounds good. If you want any help with figuring out any future problems, feel free to open another issue.