This repository contains code and instructions to implement single word speech recognition on any board running CircuitPython
APACHE-2.0 License
This repository contains code and instructions to implement single word speech recognition using neural networks on any board running CircuitPython. The code and instructions were tested with Raspberry Pi Pico board, but should work with almost any board that supports CircuitPython. This work is mainly inspired from a tutorial on tensorflow's website.
Despite being highly experimental, the code is fun to play with 🙂.
Assuming we are using a Raspiberry Pi Pico:
A1
of the Pi Pico. Input to VCC of microphone board is 3.3(OUT) of the Pi Pico.GP21
of the Pi Pico.Before proceeding to next step, it is worthwhile to check if our PiPico is actually recording speech.
Once you have made all the connections, load the code present in the record_speech.py
file on the PiPico, and while the PiPico is connected to a computer, record the audio using record_speech.ipynb
notebook (running on the computer). Feel free to tweak the gain on your microphone board till you get a clearer recording.
Copy the following files to the Pi Pico board:
code.py
stop_model_min.py
on_model_min.py
no_model_min.py
yes_model_min.py
Choose your model by uncommenting the appropriate line in code.py (only one model works at a time due to memory constraints):
from yes_model_min import predict
#from no_model_min import predict
After copying the files, your board will reboot. Wait for the yellow LED to flash (this takes about 30 seconds). This means the system is ready. Now, press the pushbutton and speak the word you want the Pi Pico to recognize (like "on"). The yellow LED will light up for a second – make sure you speak while it's on. If the word is detected, the green LED will blink a couple of times. If not, give it another try!
Try to play around with detection threshold in code.py
to increase accuracy of detection. Modify this line:
#change 0.70 to whatever works for your model.
if prediction[0] > 0.70:
detected()
Want to teach your Pi Pico new words? Check out this Kaggle notebook for instructions on training a model using the 'Speech Commands Dataset'.
For more insights into the feature extraction technique employed in the project and the methodology used for model training, please refer to the article below:
https://ashishware.com/2024/05/20/pipicospeech/
1. Intermittent USB Error on Windows 10
2. Slow Startup
3. Limited Accuracy and Unrelated Word Detection