Raspberry Pi OS has updated to Kernel 6.6 from 6.1. This tutorial has been updated to work this update. |
How I installed OpenVoiceOS over top a fresh install of Raspberry Pi OS Bookworm (64-Bit)
TL;DR – Just show me how you did it
In an earlier post, I had mentioned I installed Mycroft-AI onto Raspberry Pi 4 Model B 8gb for a personal project. Mycroft-AI is an open source virtual assistant similar to Alexa, Siri, and Google assistant. I had some trouble installing it, because I am very very new to python. After some trial and error, I got the thing installed, and tried running it with a cheap usb microphone and using headphones in the 3.5mm jack. Things did not go well.
Looking for better sound gear, I picked up an Adafruit Voice Bonnet. The Voice Bonnet sits right on top of the Raspberry Pi, and is connected via the Pi’s 40 pin GPIO header. It has 2 built-in microphones, and two sockets for speakers, among other goodies (programmable Button, LEDs, etc).
If you decide to buy an Adafruit Voice Bonnet for $24.95 USD, be aware that they don’t come with speakers. Adafruit sells Mono Enclosed Speaker – 3W 4 Ohm that plug right in the Voice Bonnet for $3.95 USD each. Buy two.
I got it installed, built Seeed-Voicecard from git. Tested the speakers and microphone hardware; everything works. Tried running Mycroft with the new hardware. Kind of a disaster.
Mycroft would respond to it’s wake word, make a sound signaling it’s recording, but never respond. The mic level meter would show activity while speaking to it, but it would never detect any words. Mycroft would speak it’s registration code, and once entering that code online, it never spoke again.
I went through multiple clean installs of Raspberry Pi OS, hardware drivers, and Mycroft configs. Nothing helped. Then I learned that Mycroft-AI team had basically gave up and signed over their code to OpenVoiceOS. Open Voice OS appears to be a fork of Mycroft-AI, with an active development. The nice thing is that Open Voice OS has multiple ways of being installed, OS Images, Docker Images, Python installs. Being based on Mycroft, it still uses the Mycroft wake word. This can be changed later on.
It took me awhile to figure out how to install it over a fresh install of Raspberry Pi, and it works pretty well.
Set up your Raspberry Pi
You are going to need a Raspberry Pi 4 or 5, and an Adafruit Voice Bonnet with speakers. For the rest of this tutorial, every time I say ‘login’, I mean ssh (secure shell) using what ever terminal program you prefer. I’m installing this as a headless system. If you are logging into Raspberry Pi’s GUI, you’ll have to fire up your favorite terminal to enter these commands. I think its a lot easier to login via ssh.
First install a fresh copy Raspberry Pi OS Bookworm (64 bit) using Raspberry Imager. Install it into your Raspberry Pi 4 Model B ( I use the 8 gb model), and boot it up. After a few moments ssh into it and login. Update the operating system.
sudo apt update
sudo apt dist-upgrade
Now we need to edit /boot/config.txt
sudo nano /boot/config.txt
sudo nano /boot/firmware/config.txt
- config.txt has been moved in latest versions Raspberry Pi OS
Find the line that says dtparam=audio=on
and change it to #dtparam=audio=on
Find the line that says dtoverlay=vc4-kms-v3d
and change it to dtoverlay=vc4-kms-v3d,noaudio
and save the file. This disables the Raspberry Pi’s built-in sound hardware. Next load up raspi-config.
sudo raspi-config
Select “Advanced Options”, and “Expand Filesystem”. This tells the operating system to use all of the space on the SD card it’s installed on. Exit out and if it doesn’t ask to reboot, then type:
sudo reboot
If you haven’t already, place your Adafruit Voice Bonnet on your raspberry pi. Make sure your line up the 40 pin GPIO Header correctly, and seat it firmly. Probably best to do this with the power off. To power off your Raspberry Pi, type: sudo systemctl poweroff
When your done, boot up your Raspberry Pi and login.
Update Python and Libraries
Now we are going to install Python libraries in Python’s Virtual Environment (VENV). For more information on VENV, you should check out: About Python virtual environments. Most of the next set of instructions was taken from Adafruit’s Voice Bonnet Install Instructions, with minor modifications by me to ease the install process of this particular setup.
sudo apt install python3-pip
sudo apt install --upgrade python3-setuptools
sudo apt install python3.11-venv
python -m venv .sndcrdenv --system-site-packages
Now you must activate the new python environment:
source ~/.sndcrdenv/bin/activate
Your prompt should look something like this: (.sndcrdenv) $
Until Voice Bonnet is up and working, you need to have that python environment active. Every time you reboot, use source ~/.sndcrdenv/bin/activate
to enter the python environment. After the Voice Bonnet is up and running, you won’t need it anymore. Just for completeness sake, you can exit the environment by typing deactivate
Next we install Adafruit Blinka Libraries:
pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
sudo -E env PATH=$PATH python3 raspi-blinka.py
Let it do it’s thing, and when it asks you to reboot, choose yes. After you re-login, make sure to enter the python environment: source ~/.sndcrdenv/bin/activate
. Next we check I2C and SPI are enabled:
ls /dev/i2c* /dev/spi*
You should get a response similar to: /dev/i2c-1 /dev/spidev0.0 /dev/spidev0.1
You may have some extra entries, this is fine. Next we are going to run a little python script to see if the blinka installed correctly. type nano blinkatest.py
and copy and paste the following:
import board
import digitalio
import busio
print("Hello blinka!")
# Try to great a Digital input
pin = digitalio.DigitalInOut(board.D4)
print("Digital IO ok!")
# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")
# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")
print("done!")
Save the file. Make sure the Python environment is loaded, and then type: python blinkatest.py
You should get something that looks like:
Hello blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!
If you got something different, or errors, then try installing the blink libraries again. Otherwise continue.
Next we’ll install the CircuitPython DotStar and CircuitPython Motor libraries. The DotStar libraries can be used to control the programable LED’s, not sure what the Motor library is used for, but it’s part of the original install instructions. Type:
pip3 install --upgrade adafruit-circuitpython-dotstar adafruit-circuitpython-motor adafruit-circuitpython-bmp280
Next we’ll install Voicecard Software. First check for I2C support. type: sudo i2cdetect -y 1
You should get a print out of rows and columns, and under Row 10, Col a there should be an entry of 1a or UU. If there isn’t, you can try moving forward and see what happens, but probably be better to go back and see if you missed anything. Make sure you are in the python environment, if your not then type: source ~/.sndcrdenv/bin/activate
.
Before we get into the next code block, you will need to know what Kernel Version your copy of Raspberry Pi OS is using. You can do this by typing: uname -srm
You should see something similar: Linux 6.6.20+rpt-rpi-v8 aarch64
The numbers we are looking for are the Major and Minor version numbers, in this case it’s ‘6.6’
When you get to the git command below, you want to use v<major>.<minor>
For example: if the Major/Minor is 5.9, then you would type: git checkout v5.9
Or if the Major/Minor is 6.1, then you would type: git checkout v6.1
Next type:
cd ~
sudo apt-get install -y git
git clone https://github.com/HinTak/seeed-voicecard
cd seeed-voicecard
git checkout v6.6
sudo ./install.sh
After it does it’s thing and everything is installed, reboot the system
sudo reboot
At this point, you no longer need to use the .sndcrdenv python environment, but don’t delete it yet. If you still have the (.sndcrdenv) $
prompt, type: deactivate
Testing the Microphones and Speakers.
Now we will determine the Card and Device numbers. Type:
sudo aplay -l
This should give you a list of playback devices. If you edited the /boot/config.txt like I described above, there should only be one entry. If there are more than one entry, you are looking for the one that has the word ‘seeed’ in it. Write down the numbers after ‘card’ and ‘device’. Next type:
sudo arecord -l
This will give you a list of the capture devices. Again there should only be one entry, and the one we are looking for has the word ‘seeed’ in it. Again, write down the numbers after ‘card’ and ‘device’. Next we are going to create a .asoundrc file for alsamixer, raspberry pi’s default mixer. Type:
cd ~
nano .asoundrc
Copy and paste the following into it:
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:<card number>,<device number>"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:<card number>,<device number>"
}
}
Replace <card number> and <device number> with the numbers you copied from aplay and arecord commands. The arecord numbers go into the pcm.mic section. The aplay numbers go into pcm.speaker section. The end result should look something like this: pcm "hw:0,0"
or pcm "hw:2,1"
, just make sure that the number are ones you wrote down. Save the file. This sets the default sound and microphone for alsamixer. Next type: alsamixer
Hit ‘F3’ and set the audio volume levels to what ever you want. Hit ‘F4’ and set the Microphone Gain to about 50-60. Hit ‘ESC’ to exit. Now we test the sound. Type:
speaker-test -c2
You should now hear white noise coming out of the speakers attached to the Voice Bonnet. First the left and then the right. Hit ‘CTRL-C’ to end the sound test. If you heard sound, proceed to the next test. If you didn’t hear sound come out of the speakers, you can try rebooting the system, or deleting the .asoundrc file you just made, or going back and seeing if you missed something.
Warning: This next test sometimes results in a sound feedback loop very quickly. Be ready to hit ‘CTRL-C’ quickly to end the test. To test the microphone, the next command will record sound and immediately play it the speakers, basically creating an echo chamber. Replace the number in -Dhw:#
with the Card (not device) number you copied down. Type:
sudo arecord -f cd -Dhw:0 | aplay -Dhw:0
If you get sound, congratulations! You’ve correctly installed Voice Bonnect and its ready for use! If you didn’t get sound, then something went wrong. Try going back and see if you missed something. you could also open alsamixer again and increase the microphone gain.
Installing Open Voice OS
First we make sure curl is installed. Then we use the automated installer for Open Voice OS. Instructions for the installer is located at https://github.com/OpenVoiceOS/ovos-installer. Type:
sudo apt install curl
sh -c "curl -s https://raw.githubusercontent.com/OpenVoiceOS/ovos-installer/main/installer.sh -o installer.sh && chmod +x installer.sh && sudo ./installer.sh && rm installer.sh"
Then follow the instructions displayed on the screen. You’ll be able to select language, whether to use containers (Docker) or virtualenv (Python VENV), Extra Skills, etc. A few notes:
- I’m not a particular fan of Docker, I don’t care for containers, So I chose the Python install. I believe if Docker is not already installed, this script will install it, if containers option is chosen.
- When asked whether OVOS, Satellite, or Listener; choose OVOS. I believe Listener is a listening server and Satellites connect to the listener to get answers.
- When ask about GUI, leave it unselected unless you have KDE Plasma desktop installed.
And thats it! Try it out, and say:
“Hey Mycroft, What time is it?”
“Hey Mycroft, What’s the weather like?”
“Hey Mycroft, Who made you?”
“Hey Mycroft, Who is Ada Lovelace?”
Later on you can change the voice, wake word, and skills of your new Open Voice Installation.