Moode Forum

Full Version: How to run other applications accessing sound devices?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi there,

I currently have a couple of moode players in my home and I'm also playing around with snips.ai (voice assistant).

It would make sense to have this on the same Rasperry PIs as they are positioned well and would make a great
assistant.

However, I'm not sure if this works or if it will cause problems - did anyone maybe try this?
if I try to run it I keep getting this output:

https://gist.github.com/solars/1c326fe86...777d74b128

My questions are:

a) I don't see an asound.conf or asoundrc file, people reported that specifying the cards in there fixes the errors.
How does moode handle this?

b) If I, theoretically, get it to run - is it even possible to run this in parallel?

c) If not, would it work with a standard Raspian Image where I install moode and snips afterwards?

Thank you for your help
can anyone help me?
(03-19-2019, 06:41 PM)chbla Wrote: [ -> ]can anyone help me?

I can speak only for myself.

1. I know nothing whatever about snips.ai.

2. I don't understand what you are trying to accomplish by running snips.ai and moOde Audio Player side-by-side.

3. moOdeOS and moOde Audio Player are designed to work as a harmonious whole with the expectation that they are in control of the Linux audio system.

I suppose it's possible that someone lurking in this forum can help but I think you would have better luck asking your questions on the snips.ai forum. I wouldn't ask there specifically about snips.ai and moOde, but about snips.ai and MPD. Keep in mind that any recommendation made there regarding mpd.conf may conflict with moOde.

I also think it would be simpler to just get another RPi for your experiments with snips.ai. YMMV.

Just my two cents worth. 

Regards,
Kent
Thanks for the reply Kent,

I understand it is easier to just run a separate Pi for the assistant. However, honestly if I have
a multi room audio setup with perfect speaker placement etc, it bothers me to not be
able to run my voice assistant there as well.

From my perspective this would totally make sense.
The other point is I don't want to waste resources, it's simply overkill to have 2 RPis in
6 rooms while it is not needed and technically should be possible...

But that's just my point of view... and I of course understand the benefits of providing a complete
image.

Anyway, is there any way to install Moode on an existing distribution? I think this was possible in earlier
days, would it help anything?

I'm not very familiar with the linux sound systems, should Snips use MPD then instead, or how would that work
in an ideal world (theoretically)?
@chbla

You still haven't said what you want to accomplish with snips.ai. If what you have in mind is to replicate an Alexa-based Amazon Echo or a Google Assistant-based Home Smart Speaker using moOde, an RPi, your audio setup, and a microphone, then you have your work cut out for you. It's not impossible but it takes some programming chops. You have to deal with audio in/out and with command/control.

If you are "not very familiar with the linux sound systems" then you first need to do your homework regarding the advanced linux sound architecture (ALSA). Then you can read the moOde source code to see how it uses the ALSA subsystem by way of the music player daemon (MPD) or several alternative renderers. Pay attention to how moOde configuration panels can change the specifics.

Now you'll be in a position to figure out how you want to make snips.ai and moOde play together in the same "audio sandbox". If you want actually to control moOde using snips.ai then you also have to understand the snips.ai API and the moOde/MPD APIs and write the glue code that makes it happen.

As for building moOde on some other distro, see moOde's github site for source code. In particular, read and understand the build recipe. From first to last, this recipe addresses only the use of Raspbian to build a moOde binary which combines moOdeOS (a customized Raspbian) and the moOde player. You'll have to interpret the recipe liberally to build the moOde player on some other software distro. Expect bumps and detours along the road.

I don't know what you don't know so I'm trying, perhaps too pedantically, to sketch the whole picture. It's up to you to fill in all the dots.

Regards,
Kent
@TheOldPresbyope I will look into it if I have time, right now I don't.

This leaves me with the following setup in only one of my rooms:

1x RPi for Librelec/Kodi
1x RPi for Snips
1x RPi for Moodeaudio

This is very far from an ideal world imho given that a) they are not used at the same time and b) could use the same hardware.
I agree that it would be ideal if all these media players could simply be made as installable apps that could coexist with one another on a common operating system. Unfortunately thats generally not the case and in fact its just the opposite. Typically each media player runs on top of its own custom operating system and audio stack.

On the other hand Snips is probably designed as an app thats independent of the underlying OS so I'm sure its possible to integrate it with moOde. Your challenge will be to convince a developer to spend the time to do it.

-Tim
@chbla

Curiosity got the better of me. I went off and read the material available on snips.ai. Based on that, I have to walk back some of my early remarks---it looks like making a snips assistant similar to, say, Alexa would be easier than I thought.

So, I set up the snips command interface on my laptop and installed the snips platform on a moOde r5.0 player/RPi3A+. This test installation has a Plantronics USB gaming headset plugged in and selected as the MPD audio device. 

I see the same stream of error messages on the RPi that you reported. It appears from them that the snips platform runs through a number of guesses of possible ALSA device names. I can't comment on that or on any other aspect of the snips' usage of ALSA because I couldn't find any documentation of the core snips platform.

So, I just went ahead and ran "snips setup audio": 

Quote:kreed@T520 ~ $ sam setup audio
? Is it a Snips Makers Kit? No
✔ Found only 1 capture device named: card 1: DSP [Plantronics .Audio 655 DSP], device 0: USB Audio [USB Audio]
i Using this device to capture sound 
? Found 3 interfaces to output sound.
  Choose the one you want to use as your speaker card 1: DSP [Plantronics .Audio
 655 DSP], device 0: USB Audio [USB Audio]
✔ Installed /etc/asound.conf

Snips automatically selected the headset's microphone because that's the only capture device present. It offered me a selection of three ALSA devices for the speaker: the first corresponds to the RPi onboard audio jack, the second to the RPi onboard HDMI output, and the third to the USB headset.

1) as you can see in the code block above, I selected the USB headset. As a result, sam wrote a /etc/asound.conf file to the RPi containing my choices.

Running "sam test speaker" and "sam test microphone" didn't result in me hearing anything other than the moOde selection already playing on the headset.

2) Then I reran "sam setup audio" and selected the RPi onboard audio jack as the speaker, and plugged a set of earbuds into it. As a result, the /etc/asound.conf file got updated. 

Now "sam test speaker" continuously plays the prerecorded "front left, front right" through the earbuds----while moOde is playing through the USB headset. Similarly, running "sam test microphone" results in my spoken test phrase being played through the earbuds.

What I've seen so far suggests to me that you don't have to do nearly as much hard work as I was prophesying earlier. My test #1, though, shows there is a bit of work to be done yet. I believe the microphone input actually was being captured but the test output wasn't making it to the USB headset because of a clash between snips.ai and moOde/MPD ALSA usage.

This is all I'm going to do for now. If I can get some time to play with snips.ai some more, I may try creating an assistant as an voice-activated version of the popular moOde LIRC controller. Just for fun.

Regards,
Kent
Pages: 1 2