Created By: Swapnil Verma
Public Project Link:
Project Demo
Story
Problem
Many times in an application, we want to identify the environment of a user, in order to automatically carry out certain tasks. For example, automatically switching on/off ANC (Automatic Noise Cancellation) in a headphone based on the user's environment. Or, in some applications leaving GPS turned on might be overkill and drain a battery's charge.
In situation's like this, can we detect a user's local environment without the use of GPS?
A Solution
We, humans, are good at understanding our environment just by using auditory sensory skills. I can identify a multitude of sound sources and also guess an environment just by listening. In this project, I am trying to replicate the same behaviour using a TinyML board with a microphone, running a machine-learning model.
Hardware
Training Pipeline
As you might have guessed already, I am using Edge Impulse for building a TinyML model. Let's explore our training pipeline.
1. Data Collection
A good machine learning model starts with a high-quality dataset. I am using the [ESC-50] public dataset, to prepare my own dataset.
I have prepared a total of 7 classes denoting various locations, by combining some of the classes from the ESC-50 dataset. The classes I have prepared are:
Airport (aeroplane and helicopter sound)
Bathroom (brushing and toilet flush sound)
Construction (jackhammer sound)
Home (washing machine and vacuum cleaner sound)
Road (siren, car horn and engine sound)
Work (mouse click and keyboard typing sound)
Anomaly (quiet environment sound)
I have used only the ESC-50 dataset to prepare a new dataset for this project. The sound samples contained within any of these classes are not the only representation of that class. They can be improved by adding more sounds from different sources.
2. Impulse Design and Preprocessing
The first thing to do for training an ML model is Impulse design. It can also be thought of as a pipeline design from preprocessing to training.
In the pre-processing block, start with the default parameters. If required then change the parameters to suit your needs. In this project, the default parameters worked perfectly, so I just used them.
After adjusting the parameters, click on Generate features.
3. Model Training
My model, trained with 1000 epochs and 0.0002 learning rate has 89.2% accuracy, which is not bad. This tab also shows the confusion matrix, which is one of the most useful tools to evaluate a model. This confusion matrix shows that the work class is the worst-performing class in our dataset.
The pre-processing and NN classifier tab automatically adjusted itself for 6 classes instead, after the dataset was modified.
4. Model Retraining
This will re-run the pre-processing block and learning block in one click, with the latest parameters.
After retraining the model with these parameters, the training accuracy is now 92.1%.
5. Model Testing
Thee Road class has the worst performance. Let's investigate why. Scroll to a sample which was classified incorrectly, and click on the 3 dots to get a menu, and then click on Show classification.
This will show the result of each window of that sample. In the Raw data section, we can also play the audio corresponding to that window, giving us more insight into why the sample was incorrectly classified.
6. Deployment
Live Testing
Let's test the model after deploying it on the Syntiant TinyML board. You can check it out in the below video.
3D-Printable Case
To download a protective 3D-printable case for the Syntiant TinyML board, please follow the below link:
Edge Impulse Project
To clone this Edge Impulse project please follow the below link: