Picovoice is a platform for adding your own customised voice control to your product. It allows complete control over the voice commands your device listens for, and the actions it takes in response, all wrapped in an easy to use web interface and generous free tier account.
This repository provides an example of running Picovoice on a Raspberry Pi 4 using balena.io. It wraps the balena scan
CLI command to allow listing of devices on your network and some of the configurations of those devices. It is designed as a demo and starter project to use Picovoice and instructions on how to build it for your own uses are included below.
Get started by saying picovoice
. Picovoice will reply yes
and wait for your instruction, which can include one of the following:
What devices are on my network?
- Performs a scan of your network for balena devices and returns a numbered list
Scan for devices again
- After the first scan the results are cached and future commands will return data from that cache until either a restart or you ask picovoice to
scan for devices again
.
How many devices are on my network?
- Scans for devices if a scan hasn't already taken place and reports the number of available devices
What is the kernel version of device 1?
- Reports the kernel version of device 1
What is the operating system of device 2?
- Reports the operating system of device 2
What is the architecture of device 2
- Reports the architecture of device 2
This project is built for the Raspberry Pi 4. Picovoice says it also works perfectly well on Raspberry Pi Zero 2 although I was unable to source the hardware to test on and therefore this repository is currently only compatible with Raspberry Pi 4.
On top of the Raspberry Pi 4 goes the ReSpeaker 2-Mics Pi Hat which provides the microphones and speaker output for Picovoice.
I then used a 3w Mono Enclosed Speaker plugged in to the HAT for sound output.
All of this hardware is push fit, with no soldering required.
Internet access is required to communicate with the Google Translate API that allows voice responses.
-
Register for an account on the Picovoice console where you will be able to obtain an access key.
-
Deploy the application as a fleet to the balena Cloud. Don't worry, we have you covered, there is one-click setup link at the top of this README.
-
Expand the advanced option on the
Create and deploy to fleet
window that appears for your balena account. Configure theFleet configuration
with the following:Name Value RESIN_HOST_CONFIG_dtparam "i2c_arm=on","spi=on","audio=on","i2s=on" RESIN_HOST_CONFIG_dtoverlay "vc4-kms-v3d","i2s-mmap","seeed-2mic-voicecard" -
In the same window, configure the
Fleet environment variables
with your access key:Name Value ACCESS_KEY your-key-from-picovoice Example configuration
Then hit the
Create and deploy
button. -
In the next screen, press
Add device
. Select OS versionv2.99.27
which is the OS configuration the overlays provided in this repo are built for. Then configure the other options including WiFi settings as required (you may need to tick theShow outdated versions
checkbox to see the2.99.27
OS version). -
Click
Flash
and you will be taken to balena Etcher ready to flash the image to your SD card. -
Once you have flashed the image to your card, mount the card on to your system and open the root of the filesystem. Copy
overlays/2.99.27/seeed-2mic-voicecard.dtbo
found in this repository to the/overlays/
folder on your mounted SD card. -
Plug your SD card in to your Raspberry Pi, boot the device and it will begin to download and install the required software.
Picovoice is designed to be completely customisable. I have chosen to demonstrate Picovoice by wrapping the balena CLI, but it can be used for any purpose and you can easily configure your own voice commands in the Picovoice console. This code repository is designed to try and make that build as easy as possible.
Here are some steps to build this project for your own purpose:
-
Login to the Picovoice console, navigate to
rhino
- which is the Picovoicespeech-to-intent
engine - and follow the Picovoice docs to build your own voice commands through their web interface. -
Once you have configured your voice commands you can export a
.rhn
file from the Picovoice console. Replace the currentconfig/pv_config_files/picovoice_voice_commands.rhn
with your new.rhn
file. -
You can now configure what you want the device to do when it hears your chosen commands. All of the configuration is done through the
config
directory of this repository.- The
intents.py
processes theIntents
configured in the dashboard slots.py
processes the slots configured in the dashboard, based on the available slots under theintent
.
Much of the language of
intents
andslots
will become clearer when configuring your voice commands in the Picovoice console. - The
-
Feedback here or on the balena Forums on the experience and lessons learnt.
-
Enjoy your own custom built voice assistant!