Turning off speaker when mycroft is not making sound

Hi. I’m building my own mycroft and I would like to know if it is possible to know from code when it is making sound. The reason for this is that in my particular setup I’m going to put the sound through an amp before it goes to the speaker (because I’m using quite a large speaker) and I would like to be able to turn off the amp when no sound is coming out. Some ideas I had for doing this were

  • Listening to pulseaudio events
  • hooking into the code that talks to the mark-1 enclosure.
  • a modification to mycroft-core

Not after a fully fleshed out solution, just opinions on what the best way to go about this is.

1 Like

Look at the message bus. You could maybe listing for some events and if there is something turn on the amp.

1 Like

Yeah, listening for the audioservice and recognizer_loop messages seems like the way to go.

Would you leave the amp running for some period of time following an interaction given it’s more likely that another event will happen shortly?

Would love to see a video when you get it working too :slight_smile:

1 Like

Thanks for the replies. Yes, I’ll probably leave the amp running for a bit after I think that the audio. Seems to make send that if it’s just played some audio it will need to play some more soon.

Probably won’t do a video, but there will be a write-up on my blog about how I build this, so I can post that on the forum.

2 Likes

I’ve actually had to modify the mycroft code to add in a new message that gets triggered after the wakeword is found, but before the found wakeword tone is sounded in order to be able to do what I want.

I’ve made a pull request with this feature added: https://github.com/MycroftAI/mycroft-core/pull/2367