In this workshop will will explore word recognition using Edge Impulse and the Arduino Nano Sense microcontroller board.
Word recognition can be used to control devices through voice commands. Systems such Apple's Siri or Amazon's Alexa are voice controlled devices triggered by a Wake Word (‘Hey Siri' or ‘Alexa' respectively).

In this wo0rkshop we will train a simple model to recognise ‘Yes' and ‘No'.

A partial Edge Impulse has been created to get you started. This has been populated with a small subset of Yes and No samples from the Google speech command dataset, so you have some data to work with, which will help keep the noise down in the lab!

The project can be found here:
https://studio.edgeimpulse.com/studio/1174700

You should Clone the project so you have your own copy to work with.

Navigate to the Create impulse section in the left hand panel under Impulse design.
Edge Impulse will provide a default Input block according to your data type.
However edit the Input block to use a Window size of 2000 ms (see below).

alt-text-here

This will make collecting your own data or performing live classification easier as a 1 second window is quite short for capturing a sample. Ensure Zero-pad data option remains checked. This pads out the sample with zeros if your sample is shorter than the window size.

Now add a processing block. Edge Impulse will provide some guidance into the most suitable type of processing block.

Now add a learning block. We are doing Classification, so add the most appropriate block.

Finally, click Save Impulse to save the impulse.

Now go to the processing block (if your choice of processing block was correct this is labelled MFCC). Notice how MFCC signal processing produces a Cepstral Coefficients spectogram for each sample. For a first attempt it is OK to accept the default parameters by clicking Save parameters. Then Generate features. The resulting feature explorer will give you some idea how easy it will be to classify your data.

Now you are ready to train the model. Navigate to Classifier. Again, for a first attempt you can stick with the defaults. You will notice that the default network architecture is a 1D CNN. This is because the MFCC spectrogram has similarities to an image for the purposes of classification. Go ahead and press Save & train.

When the training has finished you should see the accuracy of your model based on the validation data set (remember, Edge Impulse automatically splits your ‘Training' dataset into a training and validation dataset).

Now we are going to test the model. First, we can test the model against the held out test dataset using the Model testing option.

But the real test is to try some live classification using your own voice and the microphone on the Arduino Nano Sense. To do this you select the Live classification option and connect your Arduino Nano Sense using Web USB as we saw in last week's workshop. Make sure to use a sampling length of 2 seconds (see below)

alt-text-here

Now collect some samples and use the model to classify them. How does the model perform? Probably not as well as you found using the Test dataset. Why might this be?

The model might not perform that well on live classification, because it's hearing a new voice recorded using different hardware (the microphone). Also with such a small training sample the model may have overfit (learnt) the training dataset. So lets supplement the Google spoken words data with some of your own training data. Go back to Data acquisition and select the Collect data option. Again you can use Web USB to collect training samples from the onboard microphone of the Arduino Nano Sense. Collect some new ‘yes' and ‘no' samples. When you have collected a reasonable sample, repeat the preprocessing (you will need to repeat feature generation as you have new data samples) and training workflow to create a new model.

Test this new model particularly for live classification. Has the accuracy improved?

When you are happy with the model accuracy, the final step is to deploy it to your Arduino Nano Sense microcontroller. Go to theDeployment option (see below) and follow the process you used in last week's workshop.

alt-text-here

Once you have installed the library in the Arduinoi IDE, open the appropriate example sketch (nano_ble33_sense_microphone) and upload it to the microcontroller.

How does it perform for on device classification? Try customising the example sketch so it drives the onboard RGB LED, perhaps using green for ‘yes' and red for ‘no'.