Poor performance of Light on/off implementation

I have read 3 different articles on guys implementing the Light on/off example and also seen the video here on Edge Impulse.

I have created a project and followed the instructions and also get very nice results, when tested the model, but when I try the model on my Arduino Nano 33 I get mixed results… It I don’t say anything and just watch what is going on sometimes, the Light turn on and then off for a while… If I say the “Light on” command, it sometimes work… I have tried to add morer noice and more “Light on” + “Light off” test data, but it doesn’t seems to do anything.

I have also tried with just one word like “Hi Hugo”, but I get the same results like, nice model testing in Edge Impulse, but poor performance on the Arduino.

Hope anyone can help me out

I think I found a part of the problem…

In the Arduino sketch when the recording is starting, the microphone only record for about 1 sec. (I think) If you have a 2 sec. speech command it goes wrong, like my “Light on” command (all my commands is recorded in a 2 sec window)… also when the “Recording…” is shown in the serial monitor, you have to be fast and tell your command right away :slight_smile:

I tried with yes/no commands and also recorded them in a 1 sec time slot… After some time and getting used to speak right away, when the “Recording…” is shown, it works perfect.

Now I would like to increase the microphone recording buffer to 2 sec and see if this helps on my “Light on” / “Light off” problem

Hi @kelle,

The recording time is linked to the window size in your Edge Impulse project. Just increase the window to 2sec, retrain your model and deploy it back to your Arduino.

Let me know if that helps,
Aurelien

1 Like

Hi Aurelien

Thank you so much for your reply… I changed the window to 2sec and now I have 2 sec recording in the arduino program :slight_smile:

The problem now is that my model always return a classification of 0.99??? I haven’t changed anything, other than the window size and window increase size.

Don’t I have to change the sampleBuffer from 2048 to something else? Because when I only had 1 sec, the sampleBuffer was 2048…

My window now is 2000ms and I increase it with 1000ms, also I zeropad the data because my noise is still 1 sec

@kelle Just to check: are you using the continuous example? It will constantly listen rather than just for 1 second, inference, and listen again. Then you don’t need to time it.

Hi Jan

I have 3 projects I play with…

  1. yes/no (1 sec recording) speech + noise, nice model, window size = 1000ms, window increase = 500ms, just using the example nano_ble33_sense_microphone, works perfect.

  2. “hey hugo” (2 sec recording), “yes” (1 sec) speech + noise (1 sec), nice model, window size = 2000ms, window increase = 500ms, zero pad data, everything looks very nice and data is nicely separate, but it doesn’t work :frowning:

Have tried my own code, the nano_ble33_sense_microphone and the nano_ble33_sense_microphone_continuous example… In the serial monitor the model just returns numbers between 0.63 - 0.99 for the “hey hugo” key word, when I say nothing and just watch what happens.

  1. “light on” (2 sec recording), “light off” (2 sec) speech + noise (1 sec), window size = 2000ms, window increase = 500ms, zero pad data, everything looks very nice and data is nicely separate.

Basically happens the same as in (2) just here the “light on” and “light off” alternate between 0.7 - 0.99…

I think it has something to do with the 2000ms window, but I am not sure?

Hi @kelle,

As you use a 2 sec window, you will have better results if your noise samples are also 2 sec or more. Also, have you set-up audio data augmentation? This can help to avoid overfitting.

Aurelien

It works :slight_smile:

I found some test noises online, but couldn’t make it work, but then it hit me that the sampling frequency maybe was wrong and it was :slight_smile: so I changed it to 16 khz, split the file to 2 sec noise files and uploaded it to Edge Impulse… Now it works perfect…

So lesson learned… If you change your window size to 2000 (2 sec) and your test sound is 2 sec, then it looks like your noise files has to be 2 sec also… also it is important that the sampling frequency is 16khz

Thank you so much for your help

2 Likes

Hi!

Maybe this can help too: The voice model is trained on the Edge Ipulse to control the lighting and turning off of LED

Also, if you want to add some custom noise, in the Coursera course, @ShawnHymel explains how to to use a custom python script on week 3. (You can register for free on this Coursera course): https://www.coursera.org/lecture/introduction-to-embedded-machine-learning/audio-data-capture-wMOOj

Regards,

Louis

1 Like