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
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.
I’ve just started messing around with the I2S chip and the PS3 Eye Mic and can’t get it working
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)
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.
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.
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.
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.
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,
mute=False):
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:
self.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
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.
Stephane