Configuration for i2s mems microphone

Is it possible use this mic with Rhasspy?

By default it’s stereo and S32_LE, which seems to make it reject Rhasspy’s attempt to initialize it as S16_LE mono with pyaudio.

I tried using “command” configuration and specifying that it was 32 bit (width = 4) but it seemed to initialize really slowly and was therefore problematic for recording raven soundbytes for example.

Thanks!

I ended up recording with pyaudio, and converting to a 16bit wav with the python wave module.

I then streamed this converted audio to Rhasspy on MQTT

If you are on Linux, you can use ALSA plughw instead of hw.
It’ll do the resampling and format conversion automatically.

As for the stereo to mono, you can also use ALSA and create a routing PCM that only keep the left or right channel (or even sum them). Maybe plughw can do this also…

I think there might be some examples of this in this forum.

Cheers

1 Like

Really ? i don’t remember reading this anywhere in any documentation - and it is such useful info.
I have tried to use the hw: variant to minimise overhead processing on low-powered satellites, but ended up using plughw: anyway.

Did you find a working solution to use any MEMS I2S microphone with Rhasspy? I’m struggling with the same. arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v recording.wav in the command line works properly but I can’t make it work from within Rhasspy itself. I got this working command from https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test#adding-volume-control-3061641

after putting this to ~/.asoundrc as described on the linked page:

#This section makes a reference to your I2S hardware, adjust the card name
# to what is shown in arecord -l after card x: before the name in []
#You may have to adjust channel count also but stick with default first
pcm.dmic_hw {
	type hw
	card sndrpii2scard
	channels 2
	format S32_LE
}

#This is the software volume control, it links to the hardware above and after
# saving the .asoundrc file you can type alsamixer, press F6 to select
# your I2S mic then F4 to set the recording volume and arrow up and down
# to adjust the volume
# After adjusting the volume - go for 50 percent at first, you can do
# something like 
# arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav
pcm.dmic_sv {
	type softvol
	slave.pcm dmic_hw
	control {
		name "Boost Capture Volume"
		card sndrpii2scard
	}
	min_dB -3.0
	max_dB 30.0
}

I can choose from these devices:
image
but the assumed one - plughw:CARD=sndrpii2scard,DEV=0 - doesn’t work.

How can I use this microphones (in stereo connection) to be used in Rhasspy?

You can not ASR only accepts mono 16khz 16bit usually.

Or audio - Force downmix to mono on Linux - Super User

Been trying to remember but also like this

pcm.cap {
 type plug
 slave {
   pcm "plughw:myusb"
   channels 2
   }
 route_policy sum
}