Smart assistants are here and they are super cool! With voice commands you can enjoy music, trivia, shop online and control appliances! And if you are not living under a rock, chances are, you have heard of ‘Alexa’ from Amazon, ‘Siri’ from Apple, ‘Cortana’ from Microsoft and ‘Google Assistant’ from well..Google(they seriously need to work their naming game), they are soaring in their popularity with awesome features and frankly, aggressive marketing.
The good side is that they are useful and allows us to interact with technology in a more natural way, the bad side? They are listening, and you don’t know where, when, what or how these big corporations behind them are using your data, and since laws are still catching up to the tech, we are in murky waters. We also don’t have any control over the inner workings, they are what their parent company wants them to be. Enter Mycroft, the open source assistant!
Mycroft has a lot of features in common with its elder brethren, and offers something they don’t. You have the freedom to choose how it works, you can take a look at the algorithms behind their code, and if willing and able, contribute to it as well. We need this, a competitor who offers an alternative that is open to our scrutiny, the importance of this cannot be overstated.
Did I get your attention yet? Good, Let’s us now see how we can use it! If you are a fellow Raspberry Pi fan, good news, they have a Raspbian based image called PiCroft which can be downloaded from here. Install it as you would your regular Raspbian. For those who already have an OS running on your Pi or would like to try it on your regular desktop, follow the instructions below.
I will assume that you know your way around a terminal and are going to install it on Raspbian, Ubuntu, Arch or Debian. I have tested this on Ubuntu 20.04 Server LTS running on Raspberry Pi 4 with 2GB RAM.
For Ubuntu Server you will need to install some perquisites and change some settings. For others skip this step.
sudo apt-get install linux-sound-base alsa-base alsa-utils alsa-firmware-loaders alsa-oss alsa-source alsa-tools alsa-tools-gui alsa-utils alsamixergui sudo usermod -a -G audio <your username>
We will use git to download the latest Mycroft from their Github page.
cd ~/ git clone https://github.com/MycroftAI/mycroft-core.git
Run the following command, and you should see a folder called mycroft-core.
Get inside mycroft-core directory and run dev_setup.sh. This will start an interactive session with several questions and permissions that need to be answered in a Yes/No format. Almost all will be Yes if you are not a developer, but do read them carefully. It will then install all the required packages. Get a coffee, this might take some time especially on a Pi, but don’t doze off, you will need to input your password at the end to finish the setup.
cd mycroft-core bash dev_setup.sh
After about 30 min on a Pi 4, the installation should finish. Lets test this installation, use the following command to start Mycroft.
This will open Mycroft in debug mode, it will help you check if your audio is working and if the wake-word is getting detected. Now say ‘Hey Mycroft, pair my device’ . This will give you an alphanumeric code which will be used to register your device on https://home.mycroft.ai by creating an account there. This is used to setup regional settings like time zone, location etc for weather and other location and time based updates. You can opt in to their open dataset program where they use your wake-word recordings to better train the network behind the detection, you have an option to opt out as well.
To stop Mycroft type:
Troubleshooting: Frankly, It is not that easy to setup Mycroft, you can run into many problems, particularly regarding audio. But if you can learn to enjoy that, it is a rewarding experience. Click here to go to the troubleshooting page.
PS: for me the trouble was with pulseaudio, after hours of search on the internet I found a solution: I had to type ‘pax11publish -r’ in the terminal. I was SSHing into my Raspberry Pi and pulseaudio was unable to start due to some conflict with X11.
Next we will write a service script to launch Mycroft at startup.
sudo nano etc/systemd/system/mycroft.service
Now type/copy paste the following, be sure to make some changes in the path to reflect your configuration, e.g. your home folder location and username.
[Unit] Description=Mycroft AI After=pulseaudio.service [Service] User=<your username> WorkingDirectory=/home/<your username>/ ExecStart=/home/ <your username> /mycroft-core/bin/mycroft-start all ExecStop=/home/ <your username> /mycroft-core/bin/mycroft-stop Type=forking Restart=no [Install] WantedBy=multi-user.target
After saving the file and closing it, type the following to enable the service.
sudo systemctl enable mycroft.service
Use the following commands to start or stop the service.
service mycroft start service mycroft stop
That concludes this article, I hope it was of some help. In later articles, we will explore how to create custom skills for Mycroft! See you in the next one!