Build an open future with us.

Invest in Mycroft and become a community partner.

Picroft / Mycroft.AI with MATRIX Voice


#1

Hello community,

after some trial and errors I have managed to get a running installation of MATRIX Voice (on a Raspberry Pi 3B+) with Mycroft.AI (and connected it to my openHAB installation).

Here are the step-by-step instructions:

  1. Register a Mycroft account
  2. Download the Picroft Stretch Unstable image (find it on github) MycroftAI/enclosure-picroft/tree/stretch
  3. Burn the image to a micro-SD card (e.g. with Etcher)
  4. Optional: create a wpa_supplicant.conf file in the “boot” part of the microSD card with your Wifi Information:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid=“YOUR_SSID”
psk=“YOUR_PASSWORD”
key_mgmt=WPA-PSK
}

  1. Connect your MATRIX Voice to the Raspberry Pi, insert the microSD card (Optional: Connect a monitor and keyboard and/or network cable) and boot the Raspberry Pi.

  2. SSH to picroft.local (or find the IP adress from your router), login “pi” password “mycroft” (or use monitor/keyboard)

  3. Follow the mycroft.AI setup, choose “other” under microphone. Wait for mycroft.AI to do it’s thing. If you end up on the mycroft.AI command line (Log Output on top), use Ctrl+C to quit.

  4. Now it is time to install the MATRIX Voice Kernel Modules (see also: github: /matrix-io/matrixio-kernel-modules)

Add repo and key

curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo “deb https://apt.matrix.one/raspbian $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/matrixlabs.list

Update packages and install

sudo apt-get update
sudo apt-get upgrade

Reboot in case of Kernel Updates

sudo reboot

Installation MATRIX Packages

sudo apt install matrixio-kernel-modules
sudo apt-get install pulseaudio

One more reboot

sudo reboot

  1. Make sure that the MATRIX microphone is recognized:

pactl list sources short

The result should look something like this :

(.venv) pi@picroft:~ $ pactl list sources short
0 alsa_output.platform-snd_dummy.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_input.platform-snd_dummy.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 alsa_input.platform-3f204000.spi-platform-matrixio-codec.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
3 alsa_output.platform-soc_audio.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED

  1. Make sure that the standard microphone is the MATRIX Voice (kill pulseaudio, then set default):

pulseaudio -k
pactl set-default-source 2
pulseaudio --start

  1. Check the output volume

amixer

The result might look like this (notice the 1%):

(.venv) pi@picroft:~ $ amixer
Simple mixer control ‘Master’,0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 450 [1%] [on]
Front Right: Playback 450 [1%] [on]
Simple mixer control ‘Capture’,0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]

To fix this, set the volume:

amixer set Master 99%

The result of ‘amixer’ should now be this:

(.venv) pi@picroft:~ $ amixer
Simple mixer control ‘Master’,0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 64881 [99%] [on]
Front Right: Playback 64881 [99%] [on]
Simple mixer control ‘Capture’,0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]

  1. If after a reboot the volume goes back to low, put the command in the audio_setup.sh

sudo nano audio_setup.sh

Add the following line to the end of the file, then exit and save (Strg+X, then Y):

amixer set Master 99%

  1. Now you can do a test (records audio and plays it back to you)

arecord --duration 5 --rate 16000 --format S16_LE test.wav && aplay ./test.wav

  1. And another test through mycroft.AI:

mycroft-mic-test

  1. Mycroft.AI should keep telling you to register the device. Go to the Mycroft.AI website, login and add Device, then type the spoken code.

  2. Optional: Install openHAB skill

cd /opt/mycroft/skills
git clone GITHUB URL HERE skill-openhab
cd skill-openhab
pip install -r requirements.txt

Then you need to add the openHAB configuration to your ‘mycroft.conf’:

sudo nano ./mycroft/mycroft.conf

Then change the file, mine looks like this:

{
“max_allowed_core_version”: 18.8,

“openHABSkill”: {
“host”: “OPENHAB.IP.GOES.HERE”,
“port”: “OPENHAB-PORT”
}
}

Enjoy talking to Mycroft!


#2

mycroft-mic-test works but arecord --duration 5 --rate 16000 --format S16_LE test.wav && aplay ./test.wav does not. Any suggestions?


#3

Hi there @botacious,

That suggests your recording device is OK, but your playback device is not found.

If you run alsamixer can you try selecting the the playback device?


#4

It’s probably because mycroft is still running and thus blocking arecord!


#5

Hey @SpaceGlider.
Thanks for your helpful post.

I was able to follow all your steps, but sadly the raspberry pi (3b+) crashes shortly after i start mycroft.
When i stop mycroft directly after started by the boot process the raspi keeps alive. After i start using the mic (using mycroft-mic-test oder mycroft itself).
Sometimes the rasp and mycroft are alive for a minute (so i can ask questions and get spoken answers) and sometimes it crashes directly after the start.

When it crashes the raspi is still pingable over the network but doesn’t respond to ssh login oder any key press on it’s attached keyboard.

I will try to find out if the problem is the matrix voice or the mycroft installation.

Do you had any issues like that.

Best regards
Thorsten


#6

Hello @Thorsten

unfortunately I also have some stability issues. I don’t know whether it is the Mycroft/Picroft or the Matrix or the combination.

Sometimes I have to boot 3 times until it is running stable. Once it booted up stable, it is however rock solid for me and keeps running for days.

David