Mycroft on Respeaker Core V2
Respeaker Core V2 (short: RC2) is a Single Board Computer with a technical specification similar to a Raspberry Pi3 - but with some more goodies:
- builtin microphone array (6 mics) which supports
- beamforming
- noise suppression
- echo cancellation
- led pixel ring
- user button
- 4GB eMMC memory (so you don’t need a SD-card)
- JST2-connector to connect a small loudspeaker
Overall the RC2 is a nice package to run Mycroft on…
Preparation
RC2 runs with Debian 9 (Stretch). Seeedstudio (the vendor of RC2) provides prebuilt images where drivers for the onboard sound card are already installed and configured.
First you must decide if you want to install the OS to the onboard eMMC memory or run it directly from SD-card.
Go to fangcloud and navigate to respeakerv2 > debian > YYYYMMDD
.
For the eMMC option download the
respeaker-debian-9-iot-flasher-********-4gb.img.xz
.
In case you prefer to run the OS from the SD-card you should download the respeaker-debian-9-iot-sd-********-4gb.img.xz
.
Burn the downloaded image to an SD-card (e.g. using Etcher), then insert the SD-card in the RC2 card slot and power it on. When you have choosen the eMMC option it will take approximately 10 minutes to copy the data from SD-card to the onboard memory.
Configure WiFi
After the OS install you must connect the RC2 to a PC via USB cable using the micro USB port labeled “OTG”. Then run a serial console program using 115200 baud rate, 8Bits, Parity None, Stop Bits 1, Flow Control None.
Login with user “respeaker” and password “respeaker”. Then run the setup with sudo nmtui
and enter your WiFi credentials.
More detailed instructions for preparation and WiFi setup can be found here
Mycroft setup
OS update
First you should update the operating system:
sudo apt update
sudo apt upgrade
Respeaker daemon
Next step is installing respeakerd
which provides the software stack for beamforming, noise reduction and echo cancellation:
curl https://raw.githubusercontent.com/respeaker/respeakerd/master/scripts/install_all.sh|bash
Next edit /etc/respeaker/respeakerd.conf
and change the line starting with mode
to mode = pulse
Then edit /etc/pulse/default.pa
and add following lines
load-module module-pipe-source source_name="respeakerd_output" format=s16le rate=16000 channels=1
set-default-source respeakerd_output
Finally start the respeaker daemon with sudo systemctl start respeakerd
You may want to perform an audio test by:
parecord --channels=8 --rate=16000 --format=s16le hello2.wav
paplay hello2.wav
Mycroft install
Now your RC2 is ready to install Mycroft. This is done by a git-install:
cd ~/
git clone https://github.com/MycroftAI/mycroft-core.git
cd mycroft-core
bash dev_setup.sh
During the setup you will be asked some questions, here is a rundown of my recommended answers:
- Y)es, run on the stable ‘master’ branch
- Y)es, automatically check for updates
- N - skip Mimic build
- Y - Adding Mycroft commands to your PATH
NOTE: When you have chosen to install the OS on the eMMC you have only 4GB available! Whenever running dev_setup.sh
you should consider adding the option -sm
to skip the install of Mimic as this will several hundreds MB additional memory…
After setup is finished you are ready to run Mycroft for the first time:
cd ~/mycroft-core
./start-mycroft.sh debug
Respeaker-IO-Skill
I have written a Mycroft-skill that supports the LED pixel ring and the user button. You can install the skill by
mycroft-msm install https://github.com/domcross/respeaker-io-skill.git
Advanced options
Here are some advanced options, inspired by the blog of Mycroft community user @j1nx
Use RAM-disk for IPC
Mycroft uses a message bus over which the different Mycroft services communicate - the so called “inter process communication” (IPC). This will result in a lot of read and write operation to the file system which can “wear out” your SD-card. To avoid that you can redirect the IPC to a RAM-Disk:
sudo mkdir /ramdisk
The edit /etc/fstab
and add following line to the end:
tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0
sudo mkdir /etc/mycroft
Edit (new) file `/etc/mycroft/mycroft.conf:
{
"ipc_path": "/ramdisk/mycroft/ipc/"
}
Automatically start Mycroft while booting
Until now you have to manually start Mycroft each time you have rebooted your RC2. Here is how to automatically run by using systemd
:
Edit (new) file /etc/systemd/system/mycroft.service
:
[Unit]
Description=Mycroft personal AI
After=respeakerd.service
[Service]
User=respeaker
WorkingDirectory=/home/respeaker/mycroft-core
ExecStart=/home/respeaker/mycroft-core/start-mycroft.sh all
ExecStop=/home/respeaker/mycroft-core/stop-mycroft.sh
Type=forking
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
User respeaker
must be member of groups pulse
and pulse-access
, otherwise sound output will no work:
sudo usermod -a -G pulse respeaker
sudo usermod -a -G pulse-access respeaker
Then enable the “Mycroft service” by
sudo systemctl enable mycroft.service