Build SHEP (Pictures coming soon)
Posted 07/August/2020
In this tutorial we will make our own portable SHEP AI. You can modify the code to work best for your own robotic system. This tutorial will go over the hardware needed, the setting up of libraries and configuring of the Raspberry Pi to make SHEP portable. It is up to you how you want it to look and what interface you use.
Picking parts
Firstly, we will want to pick our hardware. How do we want the AI to look and interact? I have personally used the Pimoroni
Unicorn HAT 16x16. I have used th I2S Adafruit Microphone which uses pin 18 on the Pi's GPIO. You will need to consider what pins are being used.
If you decided to use the Unicorn HAT 8x8 which also used pin 18, you may want to consider using a USB microphone.
I will be using the Raspberry Pi 3 model A+, as it has a USB where I can insert a WiFi dongel, and it has an Audio jack which saves me
needing to purchase an audio HAT or module. I will get a PCB prototyping hat to attach the microphone.
Wiring it up
The HAT for the Pi fits nicely on, but our I2S requires wiring. Firstly we will solder on the I2S microphone onto the PCB. Solder it near one of the sides so your voice will reach it. The Pins connect up as follows:
- 3V to 3.3V
- GND to GND
- BCLK to BCM 18
- DOUT to BCM20
- LRCL to BDM19
Installing software
Once you have picked your hardware you will need to install the libraries. For me that will be the Unicorn Hat 16x16 library.
I will boot up my pi, connect it to the internet and open up the terminal (CTRL ALT T).
wget https://raw.githubusercontent.com/adafruit/ Raspberry-Pi-Installer-Scripts/master/i2smic.sh
chmod +x i2smic.sh
sudo ./i2smic.sh
Next we will actually install SHEP.
You will need to download all the libraries and software needed:
sudo pip3 install sounddevice
sudo pip3 install soundfile
sudo pip3 install wave
sudo apt-get install python3-pyaudio
sudo pip3 install speechrecognition
sudo pip3 install nltk
sudo apt-get install espeak
sudo python3
>>>import nltk
nltk.download()
NOTE:
If you have errors later on with espeak then you will need to install nltk like so:
>>>import nltk
nltk.download()
Configuring the Pi
We will want out Python script to load every time we turn the Pi on. This will be done using the following:
Altering the code for your own hardware
Being you set your microphone up as the default Raspberry Pi Mic, the audio should
work fine. If you have used other means for audio output rather than the inbuild audio jack
then once again, make sure it is the default.
I have added in a green dot into the corner of the eye to signify when the audio is listening.
This makes it easier to interact with. Something you may want to consider doing in your own interface.
To alter the eye code for your own blink algorithm you will need to edit 3 different functions.
recordLED(type)
displayEye()
blink()
These are the ones which need editing. The recordLED turns an LED on or off
depending if the system is recording. The other two are the ones which read in a text file and display the colours on the map.
You can set this in any way you wish, and import new libraries for your own interface.
Below shows a tutorial on youtube of how to set up the voice recognition AI. You can follow this if you wish to start the code from
scratch and add your own sensors and outputs.