I just wanted to share some hardware tips and also wondered if there are any C guru’s who maybe be able to help out.
But first here is my top tip and its not the usual budget PS3eye recommendation which unless you already have one, I think is a really terrible recomendation that has grown into some sort of urban myth that they are good.
I have a respeaker 2 mic here which is $2-$3 more than a ps3eye but it also includes audio out. Even has a little amp, couple of RGB leds, I2C and gpio connectors.
But the importance with the software EC I am trying to do is that playback & capture are on the same card.
EC doesn’t work well with different cards for input and output in fact from the manual Speex says it doesn’t work at all due to clock drift.
https://speex.org/docs/manual/speex-manual/
(also has some good pointers to optimising paramters)
EC is hugely important if you are going to play media from the same device as you get into a situation of Forrest Rhasspy and the Mic channel is so full of echo Rhasspy will not stop.
The USB beamforming mics are probably extremely good due to inbuilt DSP but for $10 you can do effective AEC.
So here is a suck it and see with EC running on a Pi3A+ & Pi4B+
2 samples with EC running and no EC
So there we have it and the Pi4 EC sample may be better because it was my first try and spent a much longer time battling with parameters.
The Pi-3 due to me listening to that test wav so many times was just install and grab you guys some example wavs, so prob could be much improved.
But what I want to dispel is the myth you can not do software EC on a PI and its huge load.
Its just not true.
Also with whats available due to ebay, aliexpress what is available from respeaker & waveshare for $10 as starter recommendation.
Don’t get a USB cam and start hooking up the mic to accompany the Pi output as results will be poor.
But you don’t have to go out and spend $70+ on some fantastic technological marvel.
The Pi3A+ $25 and the 2 Mic WM8960 for Pi for $10 is a bit of a steel where ever you source.
The software EC I have been using is based on SpeexDsp which is getting to a fair age now.
The asound.conf fifo can be installed via
Then it can be run via the cli as ./ec -i plughw:1 -o plughw:1 -d 75 -f 2048
Open up some other terminals and test with an arecord -fS16_LE -r16000 a.wav
In another terminal play back some music aplay example.wav
I have been compiling speex & speexdsp from https://www.speex.org/downloads/
Because in Raspbian alsa-plugins expects a newer version than installed and we don’t end up with the speexdsp plugins.
Due to that I noticed for some reason all are running on an RC so just compile anyway.
This is my call to someone with a smattering of more C talent and compile knowledge, which will not be hard considering my ability.
I did compile speexdsp with various options.
--with-fft=gpl-fftw3 --enable-neon --libdir=/lib/arm-linux-gnueabihf
But generally not in a comfort zone with compiling or options.
If anyone can some pointers to set CFLAGS to neon and armv7 optimisation if being native it already isn’t.
As checking for NEON in current arch/CFLAGS... no
Also I am just wondering and haven’t the foggiest how to proceed but the Pi can use VC4 for FFT.
From an old article by Mr Upton himself.
Is there a C guru who fancies adding gpu_fft to the FFT options of speexdsp?
We are mainly headless so why not?
There is one thing I noticed with https://github.com/voice-engine/ec and the frame_size is not a power of 2 and could work out as a prime which is not good for FFT I have been editing the code before make and (128, 256, 512) seem to work well and be an improvement.
Then after that we have the supposedly better routines of webrtc_audio_processing which is part of the pulseaudio modules.
Pulseaudio is great but could be considered bloat and I am not sure if the drift compensation they have added for seperate sound cards is a bonus or actually negates for embedded use.
It would be really great to get more than just the usual VAD exposed to python or some C Guru can do something similar that here we have with Speex.
I am going to continue with my parameter experiments and inept compiling and have a look at FFTW3 and see if it can be optimised for the Pi any more and does it make a jot of difference for Speex.
Prob not as the built in FFT is prob just enough for the job, but worth investigating.
But really interested if somone fancies grabbing the gpu_fft and placing in the Speexdsp code, there is the latency between cpu & gpu, but wondered if the tail_length batch is enough?