Speaker Cancellation

Any idea why this might not work within a Docker container? I can play and record from multiple applications at the same time outside of Docker (which indicates to me that my dmix and dsnoop config is working), but then when I try to play back a file from the host and from within the Rhasspy container at the same time, I get an error from aplay:

root@1530daa229ed:/usr/lib/rhasspy-voltron# aplay etc/wav/beep_hi.wav 
ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
aplay: main:828: audio open error: Device or resource busy

Is the Docker container is trying to grab the hardware device and create an entirely new dmix plugin instance within the container instead of using the existing one outside of the container?

I’ve tried linking my /etc/asoundrc.conf into the container, making /dev/snd/ available in the container, and even setting the container to privileged without any success.

This is on a Pi Zero so I’d rather not run pulseaudio and hog more CPU…

Any advice would be appreciated! Thanks!

Ooof if /dev/snd is avail then I thought that would be it.

Must be docker if running out but not in the container and pulseaudio with dbus and everything is even worse for docker implementation.

I know alsa from Mycroft experience but never run in a container.
I am a Rhasspy noob and just trying the new https://github.com/rhasspy/rhasspy-voltron which is just python virt-env
So have no idea don’t even know what you can run on a zero with rhasspy yet.

My advice would be to install in a virt-env rather than docker as prob not eloquent but as a noob its prob a fix.
Doubt you are running much else on a zero and also don’t know how much of rhasspy will run on a zero.

Unless its something as simple as the docker run needs --group-add audio aswell ? dunno guessing.
But apols as a bit stumped as thought that would just work.

[EDIT] apols
Doh you are creating a file to the asound.conf internal docker file? As it will not see /etc/asound.conf or .asoundrc from the host and not have or at least just be defaults
Also if you write changes it will not be persistant unless you add an external in the run.

I should of mentioned this doh! apols

-v /etc/asound.conf:/etc/asound.conf:ro

To the docker run

If not stumped as not really used the docker version and still very much a fresh rhasspy noob
The persistance and what is in the container can be mighty confusing at times

This is what I did, as I mentioned in my first post when I said that I tried linking my asoundrc.conf into the container. The container uses the host’s config successfully.

ALSA does take a bit to get your head wrapped around it all, but I feel like I’ve got a good grasp on it at this point - at least on the host directly. It’s the Docker game I’m still trying to figure out :slight_smile:

Thanks for the ideas! I’ll keep poking around.

Yeah as apols as same, thought that would just work.
Maybe its just a matter of https://rhasspy.readthedocs.io/en/latest/installation/#virtual-environment as really don’t know.
aplay --verbose see if it gives a clue, someone on here will know as sure this must be a common thing.

I’m sure if I ran Rhasspy through venv, I wouldn’t be having the issue… It’s something with Docker for sure.

No difference in the output with aplay -v in the container or out of it. I just get the error message inside the container whenever something is already playing out of it.

Yeah not really sure how to get more debug from alsa as its tricky if the logs and verbose output don’t give a clue.
Maybe alsa-info would show something but doubt it.
I would post elsewhere as the title of this thread is prob stopping replies.
Or Venv as presume on a zero being in a container is of little benefit.
Maybe just needs a unique ipc_key to host such as ipc_key 555555 and maybe create a asound.conf in $HOME as a dumb conatiner file or something so they can have different keys.
But dunno that is a straw clutch.

@fastjack

1st card to turn up is the 4 mic linear 4 Pi.

So not using loopback and running ec rather than ec_hw

The ec load seems very low on a Pi4 no OC

Now strangely because I have the 4 mic linear I haven’t been able to run ec_hw yet as not really sure which channel is the loopback.
But will try but the 4 mic linear seems great and actually not bad for £25 but the linear mic strip suits prob a retangle ‘radio’ shape box due to length.

I am pretty sure I can add some extra filters forgot the music term but that will filter out the low volume and that should reduce even further.

Speex & EC doesn’t totally remove echo and really needs the same sound card as clock drift kills its function.
But on a soundcard and presuming the 2mic will be the same its likely effective EC can be used to give a mic signal fit for purpose.

Now what I have to do is figure out how to install the drivers with rt-prempt kernel and see if that gives any improvement.
I ran with default EC settings so should also give that a play and think my pi4 is about 50ms latency so used that.
But I would say that this will run on a Pi3a+ dunno about the zero though.

I am using https://github.com/voice-engine/ec not sure what the speex alsa-plugins actually do?
Still got it set up via alsa with the ec asound.conf
Whats the term for a musical filter that removes the low volume portion of a wav?
But prob a few things I can still do to improve further.

1 Like

Sorry I did not read whole topic, but I can confirm, that Respeaker Mic Array v2 (USB) work very well with AEC (so MIC listen while audio is being played via same card). I reflashed firmware to 48kHz 1 mic channel. The only problem was to get Respeaker card working both output for Respeaker in Docker and Snapcast on host. I did solve it with help of others here on the forum.

Yeah the $70 Respeaker Mic Array v2 damn well ought to have hardware DSP :slight_smile:

You can do it with software with $10 2 mic Pi soundcards, been on a bit of a crusade to get it working.
I found that you have to have playback/capture on the same cards as since I got a 4mic linear for Pi software AEC works quite well.
The idea is satellite speaker/mics with with Pi4/Respeaker V2 USB starts to get a tad expensive.
But you can Pi3A+/2mic4Pi AEC away quite nicely for $35 and as a disclaimer haven’t tried the Pi3A+ but the load is so little on the Pi4 that I am presuming its yes.
I should get my skates on and check that.

There is a Master/Satellite form of Rhasspy that has a number of advantages and is pretty cool, but costs can quickly add up.
There is also the Software AEC of pulseaudio but again pulseaudio can be a docker pain and its adding more bloat to low end satellites that are little more than streaming speakers with mic arrays.

I think its of more interest for those who want to run home cloud AI without big data services.
But localising and distributing voice capture and creating what is essentially a wide array microphone has natural physics on its side rather than technology.

PS if anyone is trying the software.


Is slightly wrong edit ec.c so the frame size is a power of 2 and your FFT filter will be much better (128, 256 or 512) prob.
The line int frame_size = config.rate * 10 / 1000; // 10 ms even for someone like me is easy to change, then make.
The above line is likely to make primes not good for FFT.
[Pi3] with a quick test seems very much like the Pi4

Did you notice audio playback quality issue (like strange « shh ») with the 48Khz firmware?

Isn’t 16khz if you enable AEC, but that is my foggy memory but seem to remember thinking Oh so just wideband audio.

Just to update older thread, there is 48kHz firmware for Respeaker Mic Array v2 available. So AEC is now also available for 48kHz playback/recording.

Thanks. I know of it and tested it a few months back to no avail. AEC is pretty inexistant and audio playback quality suffers from strange saturation issues.

Seed has stated on their forum that the playback quality / AEC issue can not be solved because of the limited capabilities of the XMOS chip.

@litinoveweedle Hi :wave:. Can you confirm that the Respeaker 48KHz 1 channel firmware have a working AEC? Did you notice audio quality issues? Thanks :blush:

@fastjack On the topic of EC and hardware.
Got another Syba USB and again seems to be fake with a c-media mono mic chipset than the stereo via envy.

Also 2x I2S mics and a cheap china hdmi2hdmi+audio seems to work well.

Hello, sorry for late reply. The sound with 48kHz is little bit better than 16kHz, but is is far from perfect, there are some strange artifacts. AEC seems to be working but is far from perfect, especially when playing loud music.

I did checked all available MICs arrays, but all seems to be based on same chip (xmos XVF-3000), with same 16kHz limitation. I can only hope for some new MIC array with xmos XVF-3500 to arrive soon. :-o

@litinoveweedle

Could you try and help this guy out a Mic wise the Anker Anker PowerConf seems to be an amazing piece of kit.

For some reason aplay -Dplughw:1 -r16000 -f S16_LE file_example_WAV_10MG.wav works perfectly but playback from Rhasspby is cutting at the start and I am unsure why.

But might be of interest as they are a pretty new product and if aplay -Dplughw:1 -r16000 -f S16_LE file_example_WAV_10MG.wav works fine from the cli then I can not see it being the hardware.

Only thing I haven’t done is suggest creating an asound.conf defining sample rates and channels maybe summing them.

Sort of hard work remote and blind, I might take the plunge and buy one.

I’m using a ReSpeaker 4 Mic Array with a raspberry pi 3b+ and cannot run ec with “./ec -i plughw:CARD=seeed4micvoicec,DEV=0 -o plughw:CARD=seeed4micvoicec,DEV=0 -d 200”

It just says
cannot open audio device plughw:CARD=seeed4micvoicec,DEV=0 (No such file or directory)

Anyone have a respaeker 4 mic and got this working?

My arecord -L:
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
eci
eco
default
Playback/recording through the PulseAudio sound server
usbstream:CARD=b1
bcm2835 HDMI 1
USB Stream Output
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
sysdefault:CARD=seeed4micvoicec
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0
Default Audio Device
dmix:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0
Direct sample mixing device
dsnoop:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0
Direct sample snooping device
hw:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0
Direct hardware device without any conversions
plughw:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0
Hardware device with all software conversions
usbstream:CARD=seeed4micvoicec
seeed-4mic-voicecard
USB Stream Output

Dunno try aplay -l and see if you can get it to work with the index number instead plughw:2 or whatever it will be

This is my aplay -l:
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 H eadphones]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3

I might be wrong, but doesn’t this only list playback devices, not mics? The respaeker isn’t there anyway