PiCroft with I2S Audio?

Hi there,
I’m planning on building a PiCroft powered “smart radio” using an old radio. I’d like to output the sound using an I2S DAC/Amplifier combo like this one: https://www.adafruit.com/product/3006

Has anybody used something like this before? :slight_smile:

All the best,

That sounds like a fun project and could be made :slight_smile:

I only have experiance whith google voicehat, but if the adafruit thing is working on the pi I cant see why it couldnt work on a pi whith mycroft installed.
The Picroft image is basicly a raspbian strech installation whith mycroft preeinstalled and a script helping you to get started.
So I would revomend installing picroftimage, and then the adafruit and get that to work by changeing relevant alsa and config settings when you get sound out and in by testng whith aplay and arecord mycroft should work to.

Hi @schmolmo,
I haven’t used that exact breakout board before but I have used an I2C DAC with picroft and hooked that to a separate amplifier. I did consider using the one you mentioned but I already had this other one on hand. The small purple board in top left of the attached image is the I2C DAC that I used. From memory it doesn’t take too much configuration to get it going.

Great, I’ll try that. Thanks!

1 Like

Hey there,

I’ve just started messing around with the I2S chip and the PS3 Eye Mic and can’t get it working :confused:
I’ve set the I2S up using `this tutorial. The soudn playback in the setup wizard is working, but when I get to the Mic test, I receive this:
Playing WAVE ‘/tmp/test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
aplay: set_params:1305: Channels count non available
An error occured while playing back audio (1)

Any ideas?

all the best, schmolmo

I’ve had similar problems, that I’ve yet to solve. If I attempt to record with arecord with format of S16_LE I get a wav file, but the contents are all 0. If I use arecord but with a format of S32_LE I get good sound data. I notice that doing the mycroft_mic_test the audio file (which has the right number of bytes but they’re all null bytes) the format is S16_LE which might be the problem I’ve encountered using the adafruit I2S microphone.

I don’t know if there is anyway to tell it to use the S32_LE format for recording, but if there’s another solution someone has found I’m happy to try it.

@schmolmo - It’s possible to set the listener channels manually using mycroft.conf

Here’s a fairly long example configuration but roughly half way down you’ll see the “listener” attributes can be set with:

"listener": {
    "channels": 1

It’s easy to set the format of playback via mycroft.conf but I don’t think we have support for different recording formats. Let me see what I can dig up…

So, have talked to Ake and he’s confirmed that the mic format comes directly from the Microphone base class in the python package we use. It should be possible to override this, however no one has tried this so big disclaimer - editing source code can break things…

If you wanted to do this and don’t mind breaking Mycroft if it doesn’t work, try adding the following after the init method of that super class:

self.format = self.pyaudio_module.paInt32
self.SAMPLE_WIDTH = self.pyaudio_module.get_sample_size(self.format) # size of each sample

Thanks for the reply, we’ve decided to use a different audio approach and it’s working much better. We’re using the SeeeStudio Mic Array and it’s much better than the previous I2S. Recently got the websocket monitoring the MyCroft messages to integrate the light ring on the Mic Array card and it works and looks great.

Keep up the good work!!

1 Like

I’m working on embedding Picroft in an animatronic, so I added the same I2S amp as the OP (https://www.adafruit.com/product/3006) to my RPi 3B+. I also added a USB mic. I can’t get PulseAudio to play nicely.

ALSA (aplay -l) shows:
(.venv) pi@picroft:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0

But pactl info shows:
(.venv) pi@picroft:~ $ pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 32
Server Protocol Version: 32
Is Local: yes
Client Index: 29
Tile Size: 65496
User Name: pi
Host Name: picroft
Server Name: pulseaudio
Server Version: 10.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: auto_null
Default Source: alsa_input.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-mono
Cookie: b116:decf

I’ve been through all of the config files dozens of times, reloaded ALSA and PulseAudio, etc. I’m missing something simple. If I turn off PulseAudio, I can force output through the speaker, but then the USB mic doesn’t work.

Any assistance would be appreciated.

Does aplay successfully play audio? If so you can set the play commands in Mycroft with:

mycroft-config set play_wav_cmdline "aplay %1"
mycroft-config set play_mp3_cmdline "mpg123 %1"

Alternatively, do any sinks show up if you run:

pactl list sinks short

If so you can set the default sink with:

pactl set-default-sink 1

replacing 1 with the relevant number

“aplay” works only if I kill pulseaudio.
“pactl list sinks short” replies with:
0 auto_null module-null-sink.c s16le 2ch 44100Hz SUSPENDED

ALSA works. PULSEAUDIO runs, but can’t grab the sink.

I wonder if it’s a permissions issue?

Fixed. Appears to have been a permissions issue that was exacerbated by running updates on my own.

1 Like

Awesome, glad you worked it out :slight_smile:

Hi there

I’m facing the same issue described in this topic, except that my hardware configuration is different (maybe I should open a new topic …)

Mycroft is running on a Nvidia Jetson Nano with two I2S mems microphone (Adafruit sph0645) . I’m able to record and play sounds on both channels with arecord/aplay with the S32_LE format used by the I2S mics.

When doing some testing with mycroft-mic-test, the sound file is encoded in 16 bits format, and is empty :

$ aplay /tmp/test.wav
Playing WAVE ‘/tmp/test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

I tried to modify the mic.py code as suggested by @gez-mycroft :

def __init__(self, device_index=None, sample_rate=16000, chunk_size=1024,

    Microphone.__init__(self, device_index=device_index,
                        sample_rate=sample_rate, chunk_size=chunk_size)

    self.format = self.pyaudio_module.paInt32
    self.SAMPLE_WIDTH = self.pyaudio_module.get_sample_size(self.format) # size of each sample
    self.muted = False
    if mute:

and I ran mycroft-mic-test again.

The result file is now encoded in 32 bits :
$ aplay /tmp/test.wav
Playing WAVE ‘/tmp/test.wav’ : Signed 32 bit Little Endian, Rate 16000 Hz, Mono

but the sound file is still empty.

Do you have an idea on what is missing ?

Thank you for your answers


Good news, I’ve added the line
default-sample-format = s32le
in the /etc/pulse/daemon.conf file and now Mycroft is using the correct format, without having to modify the mic.py file !

I can now use the Adafruit sph0645 mems with Mycroft.