Does anyone have any recommendations on mic sensitivity improvements to either MMM-AssistantMk2 module or hotword detection in general? I have everything working beautifully, but MMM-AssistantMk2 tends to open the mic NOT only when the hotword is detected, but…pretty much any time anyone is speaking. This typically results in the module opening YouTube and playing a random r&b video (which I also can’t figure out how to stop without killing the whole mirror application).
Read the statement by Michael Teeuw here.
Posts
-
MMM-AssistantMk2 Mic/Hotword Sensitivity
-
RE: "dom" variable is undefined
@morozgrafix Spot on, I do my dev on my MacBook and test in Chrome. I bet that’s what’s messing with it.
-
"dom" variable is undefined
I get a console error on start up as follows:
Uncaught TypeError: Cannot read property ‘appendChild’ of undefined. Meaning the dom variable is undefined.
The error points to main.js line 38:
var dom = document.createElement("div"); dom.id = module.identifier; dom.className = module.name; if (typeof module.data.classes === "string") { dom.className = "module " + dom.className + " " + module.data.classes; } dom.opacity = 0; wrapper.appendChild(dom);Everything still works fine, including the custom modules I’ve built, which is actually what drove me to the forum. Since everything works, I’m not actually sure how to debug. Wanted to see if anyone else had this problem or maybe had an easy fix for a fellow perfectionist.
-
RE: Passing Variables Around
Basically yes, that’s what I’m trying to do. Would that work, assuming I set it up as a new module according to the guidelines you sent earlier? (thank you by the way, that helped a lot).
Essentially I’m just trying to be able to pull data from my MongoDB (I will probably roll this into its own module – right now I’ve committed the sin of modifying app.js directly until I get my bearings). Then use the Mongo data to populate data in other modules (think Hello World, Compliments, etc.).
It sounds like I will need to create a second module that essentially takes my Mongo data and sends it in the form of a JSON object variable to other modules using sendNotification() and then have them update the DOM to reflect the change. I know there are some nuances, but for the sake of brevity, am I generalizing/thinking about it correctly?
-
RE: Passing Variables Around
Yes, @Cato I was afraid I overcomplicated the question. I actually tried to simplify it later, but apparently there’s a time limit on editing. Let me try simplify.
Let’s say I want to take the Hello World module and base it’s text on a variable. That’s the simplest form.
So hypothetically, my config.js could look like:
var someVariable = "myString"; var config = { modules: [ { module: 'helloworld', position: 'top_bar', config: { text: someVariable } } ] }Unfortunately, using a variable in place of an actual string of text seems to break the config file. Surely there must be a way!
-
RE: Black Screen on Localhost...
Might be a silly question, but did you run
npm installon the mirror root folder to install dependencies? And you made sure node.js is installed on your machine before you got started? -
Passing Variables Around
I feel like I’m losing my mind. How do I pass a variable from js file to js file here? I’ve tried
module.exportsand the traditionalexports.name = name;in the file where it’s set, then in the file where I want to use it:var myModule = require('./module'); var name = myModule.name;But when I go to use the variable, my code editor shows me it IS available, but it blows up when I start the mirror (I get the ole “Your config is broken” message). In fact, if I add anything other than the config variable to config.js, it blows up. It seems like the export is working, but there’s something preventing additional variables from being used. What am I missing? What’s the best practice for accomplishing this?
EXAMPLE:
Say I wanted to create a
var name = "Jeremy";and show"Hi " + namein the config.js of my compliments module’s config object. Easy, right?BACKGROUND:
I have my mirror connected to a Mongo DB that also serves my personal website. I plan to use my mirror as a display mechanism for data from my site. For example, I might build an editor on my site to create new compliments, save to my db, then the mirror would show them. Or similarly, display some text from my db in the Hello World module, etc. Seems straightforward enough. The db connection is working. Just trying to get the darn variables where I need them.
-
RE: Display a Web Page
Not that I’ve seen. There’s a list of all known 3rd party modules here.
Might be an easy one to get your feet wet in building your own module.
-
RE: Voice Controlled Wake/Sleep Function
@alexyak That’a a great point – hadn’t considered that conflict. I wonder if that’s what is preventing the voice commands from working in the first place.
As an aside, I could probably solve that with a quick global variable Boolean to select whether to use voice or motion, essentially only allowing one to be on at a time (with an ‘if’ wrapper to check if true/false). Might be more complicated than it’s worth though.
Fundamentally I’m just wondering where you’re writing your functions for any new voice commands you set up. As a basic example, if I wanted to create a new voice command that just showed some “Hello World” text when I gave it some verbal command, how would you set that up?
- Train pmdl model, drop in MM root
- Add keyword info to config defaults in voicecontrol.js
- Then what? I’ve seen the function itself written in a separate module like camera.js is, in node_helper.js like motion detector is, etc. What’s your suggested best practice?
-
RE: Voice Controlled Wake/Sleep Function
@chengstark Did you get any closer than I did? Let’s call on @alexyak and see if he can shed some light.
-
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 starton 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!
-
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!
-
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!
-
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!