Awhile back, I looked into open-source alternatives to digital assistants like Alexa or Siri that I could extend and customize and came across Mycroft.
Mycroft is an open source voice assistant with practical skills (telling the time, weather, news), media support, home control, among many more here. You can even build your own skills if you want.
It can run on a Raspberry Pi using the picroft image or installed on most major Linux distros. I opted for the picroft installation mainly for a relatively quick setup.
Components
- Raspberry Pi 4 (8GB RAM) - got this as part of the CanaKit
- Micro-SD card (at least 32GB) - included in the CanaKit
- ReSpeaker 2-Mics Pi HAT
- SmartiPi Touch 2 Case
- 4 Ohm 3W Speakers (JST-PH2.0mm-2 pin Terminal)
Setting up Picroft OS
Read here.
Setting up audio
Since Mycroft is an audio-based digital assistant, getting sound input and output if crucial. For this setup I used the ReSpeaker 2-Mics Pi HAT and a 4 Ohm 3W speaker.
Installing the ReSpeaker driver
sudo apt update && sudo apt dist-upgrade
cd
git clone https://github.com/respeaker/seeed-voicecard.git
cd seeed-voicecard
sudo ./install.sh
# Disable Raspberry Pi built-in card
echo "blacklist snd_bcm2835"|sudo tee /etc/modprobe.d/blacklist-alsa.conf
sudo reboot
Configuration Files
curl -o /tmp/pulse-default.pa https://github.com/respeaker/seeed-voicecard/blob/master/default.pa
sudo cp /etc/pulse/default.pa{,.bak}
echo "set-default-sink alsa_output.hw_0_0" | sudo tee -a /etc/pulse/default.pa
echo "set-default-source alsa_input.hw_0_0" | sudo tee -a /etc/pulse/default.pa
Replace /etc/asound.conf
with this:
# Use PulseAudio by default
pcm.!default {
type pulse
fallback "sysdefault"
hint {
show on
description "Default ALSA Output (currently PulseAudio Sound Server)"
}
}
ctl.!default {
type pulse
fallback "sysdefault"
}
/etc/mycroft/mycroft.conf
:
{
"play_wav_cmdline": "aplay %1",
"play_mp3_cmdline": "mpg123 %1",
"enclosure": {
"platform": "picroft"
},
"tts": {
"mimic": {
"path": "/home/pi/mycroft-core/mimic/bin/mimic"
}
},
"ipc_path": "/ramdisk/mycroft/ipc/"
}
Add this to the end of /etc/pulse/daemon.conf
:
resample-method = ffmpeg
default-sample-format = s24le
default-sample-rate = 48000
; alternate-sample-rate = 44100
Add this to the end of /etc/pulse/default.pa
:
unload-module module-suspend-on-idle
unload-module module-role-cork
load-module module-role-ducking