EC respeaker echo cancellation

Yeah its not the duck module but if what VAD gives out I will have to watch the pulse server and d-bus I guess when it running.
It just doesn’t say anywhere like quite a lot of the freedesktop documentation it is incomplete at best.
Wondering if VAD threshold is hit then its flagged as phone.mode… dunno, doesn’t say and havent tried.

No clue what you mean this time😂

1 Like

No I haven’t really as there is absolutely zero documentation for the VAD in the pulseaudio aec webrtc module.
Apart from voice_detection=1 - VAD - Voice activity detection and was just crossing my fingers this may add or change stream parameters as it hits a threshold as coul prob use that.
Otherwise its like the beamforming and just a non implemented cul-de-sac.
So I am also the same as know there is a setting for VAD but what it does is also a mystery

PS can you change the the sensitivity of precise on the run or is that all part of its setup?

Sorry, never played with it myself.

PS from playing with RT quite a lot supports even mpg123 -T but unless you run as root and sudo it will not work.
The daemon setting for RT with pulse seem to work as it states in the journal, but would seem some apps need elevation.

Haven’t really done much with it but give it a try as wow the load rockets with the Mycroft services.
It does even make the s-pipe pi audio out sound better, still sounds relatively s-pipe but is definately improved.
The load increase you get with RT prob means its a no go though, did you give it a try?

There is a little bit of documentation in the sourcecode of pa-webrtc module - at least you can see all available parameters and their default values:

Yeah what it does still seems to be a bit of a mystery.
There are a few things that confuse me as pulseaudio seem to of added drift compensation to speex with the adjust_time and adjust_threshold but webrtc has drift_compensation that you enable and not sure even if it should apply to webrtc… ? As then it has double drift compensation but unfortunately can not turn the first off.

I did sort out why speexdsp seems to be missing from alsa-plugins.
libspeexdsp-dev is 1.2rc1 but even back to the installed alsa of 1.8.1 1.2rc2 is required.
So cloned speexdsp-dev 1.2rc2 installed then compiled alsa-plugins 1.8.1

So at least I can test speex without pulseaudio drift compensation when the 2 mic turns up.
But even with the code I am still wondering if some items make any sense :slight_smile:

I believe RT is only nice for systems that are designed to run for ionly one thing. And, yes although mycroft is to be considered a one thing. Way to many packages / software is involved to really get it running nice.

Would be nice for a very small pulseaudio satelite microhone device though, but don’t believe in it on a full fledged OS with all those different running python tasks etc.

Long story short: Nope didn’t try it.

Yeah on a Pi4 it goes over 3, but same as for a satelite microphone could be ideal.

But actually if you leave it then at about 10 minutes onwards the avg load drops quite a lot.

That is normal load I see at MycroftOS by default.

Yeah it just the initial boot.

Because it is pulling a lot of pip python packages. Also the reason, RT stuff will bite your ass big time😉

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.

Lols something like that but 2 mic for $10 is even better and no tomb stone needed,
I need to check pulseaudio and webrtc-aec next and will laters but happy with what I have so far

Sure, but that Ikea Symfonisk SONOS speaker is amazing!

But think with mics in front of the speaker even the best EC is not suitable :wink:

Ya :slight_smile:

Actually to be honest with the DSP EC high tech fangled things I presume they can just about blat anything as EC compared to beam forming is lower process and less approximation.
I was certain you should be able to do some form of effective software EC that will now stop Forrest Mycroft.
It aint DSP level but its good enough, with spending some time working on optimum settings for this Pi4.

1 Like

Will await the how-to write up. :smile:

Its just the https://github.com/voice-engine/ec

sudo apt-get -y install libasound2-dev libspeexdsp-dev
git clone https://github.com/voice-engine/ec.git
cd ec
make

Add the alsafifo

git clone https://github.com/voice-engine/alsa_plugin_fifo.git
cd alsa_plugin_fifo
make && sudo make install

copy https://github.com/voice-engine/ec/blob/master/asound.conf /etc/asound.conf

open a terminal
cd $HOME/ec
./ec -i plughw:1 -o plughw:1 -d 200

In another terminal aplay something.wav
In another terminal arecord ec.wav

When no media is playing the EC will auto bypass so the load is only when playing media.
The bad thing is that EC stops when you stop recording as seems to presume we will be silence checking and handling wavs rather than streams.

I just loaded an alsa-loopback sudo modprobe snd-aloop which will show with aplay -L and arecord -L

So pipe with arecord -Dec | aplay -Dloopback0 and use loopback1 as the ec output and that will stop the process ending on the end of record.
Maybe it should be stopped and started by the KWS dunno but the above seems to work fine?

Thats it really.
I am just going to play with the other soundcards, webrtc, rt-prempt-kernel and settings and see if anything justifies being done further.

You just need to precede the mycroft start with above commands + & at the end so they run in there own bash process and thats about it.

My Tectonic S-Pipe is far better! :slight_smile:

It wouldn’t be good to have a mic infront of those speakers but its very possible to have a mic on the front of those speakers.
If you pull apart a Google or Amazon AI Mini/Echo both have an upward facing speaker with the mics on top with very little isolation.
Sound waves are really directional and my Tectonic speaker does puzzle me slightly but if you had another port that had some acoustic isolation (bit of rubber) then from the results I am getting with software EC yeah it might be possible.
I bet also thinking about it, Google & Alexa run with bandpass filters and they train thier models that way.
I am probably not going to have a microphone on the front but like Google & Alexa it will be on top.

If I am going to employ filters to improve out of bandwidth noise it just a matter of training as such.
I have been looking at Snapcast the open source Sonos and yeah its pretty damn good.