Hiya- I am using this MEMS microphone with pocketsphinx to recognize words. Pocketsphinx (apparently) only works with 16-bit audio. The Adafruit tutorial for the I2S MEMS microphone uses S32_LE throughout and this works fine with this command
/usr/bin/arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -d 2 -V mono -v -q myS32.wav
Then I use ffmpeg to convert the 32-bit audio file to a 16-bit audio file, and Pocketsphinx works just fine. It seems like it would all work faster if arecord created a 16-bit audio file in the first place.
If I edit .asoundrc to change this
format S32_LE
to
format S16_LE
and change my run command to the new format
/usr/bin/arecord -D dmic_sv -c2 -r 48000 -f S16_LE -t wav -d 2 -V mono -v -q myS16.wav
then the VU meter quits working and the new .wav file has no audible content however it is played back.
Can the I2S microphone record 16-bit data on a Pi Zero or is this simply not possible?
I2S MEMS microphone - S16_LE
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S MEMS microphone - S16_LE
@GoldstreamSolar,
Recording S16_LE is possible. There is a great thread on this.
https://github.com/mpromonet/v4l2rtspserver/issues/94
/etc/asound.conf
Recording S16_LE is possible. There is a great thread on this.
https://github.com/mpromonet/v4l2rtspserver/issues/94
Code: Select all
apt-get install ladspa-sdk
Code: Select all
pcm.pluglp {
type ladspa
slave.pcm "plughw:1,0"
path "/usr/lib/ladspa"
capture_plugins [
{
label hpf
id 1042
}
{
label amp_mono
id 1048
input {
controls [ 30 ]
}
}
]
}
pcm.lp {
type plug
slave.pcm pluglp
}
Code: Select all
arecord -D lp -c1 -r 48000 -f S16_LE -t wav -V mono -v recording.wav
v4l2rtspserver -F 25 -W 1280 -H 720 -P 8555 /dev/video0,lp -A 48000 -a S16_LE
- GoldstreamSolar
- Posts: 34
- Joined: Wed Aug 05, 2020 5:02 pm
Re: I2S MEMS microphone - S16_LE
I will have a look. Thanks very much for the tip, Mikey!
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S MEMS microphone - S16_LE
No problem. I think the crux of it is the -c2 you had been passing versus -c1 (stereo vs. mono). Let us know what you experience.
- GoldstreamSolar
- Posts: 34
- Joined: Wed Aug 05, 2020 5:02 pm
Re: I2S MEMS microphone - S16_LE
It worked like a charm, Mikey. In fact, it works so well that I would suggest that the Adafruit tutorial for the I2S microphone should use it instead of what it's got now, because this version of the .asoundrc file solves the low recording volume at the same time as it switches to writing in 16 bit.
I would add a little note. If I type this:
it suggests that I change the hardware designation for the microphone in the .asoundrc file to this:
And there is one more thing for Pocketsphinx: the sampling rate has to be dropped down to 16000, so the record command is now
Once again, Mikey, thanks very much for your help with this!
I would add a little note. If I type this:
Code: Select all
[size=85]pi@raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: sndrpii2scard [snd_rpi_i2s_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 [simple-card_codec_link snd-soc-dummy-dai-0]
Subdevices: 1/1
Subdevice #0: subdevice #0[/size]
Code: Select all
pcm.pluglp {
type ladspa
slave.pcm "plughw:0"
path "/usr/lib/ladspa"
capture_plugins [
{
label hpf
id 1042
}
{
label amp_mono
id 1048
input {
controls [ 30 ]
}
}
]
}
pcm.lp {
type plug
slave.pcm pluglp
}
Code: Select all
arecord -D lp -c1 -r 16000 -f S16_LE -d 2 -t wav -V mono -v file.wav
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: I2S MEMS microphone - S16_LE
Awesome, glad this worked out so well. Thank you for the suggestions for improving our guide and the volume boost you noticed.
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/