Sample length is too long. Maximum allowed is 5000ms

I am trying to replicate the running faucet detection example (Recognize sounds from audio - Edge Impulse Documentation) on the Wio Terminal.

But when I click the Start Sampling button after entering a length of 10,000 ms, I get the error: Sample length is too long. Maximum allowed is 5000ms.

I noticed that in the video, audio clips of length >5s were recorded. Am I facing this issue because of using the Wio Terminal? Is there any way to record audio greater than 5s if using the Wio Terminal?

Please help.

@janjongboom @shawn_edgeimpulse @louis

I tried using the edge_impulse_data_forwarder to forward the mic data to Edge Impulse. But when I try to add a MFE proccessing block, it gives me this error: ValueError: Number of samples, -369, must be non-negative.

Full error output:

Creating job... OK (ID: 3631794)

Scheduling job in cluster...
Job started
Scheduling job in cluster...
Job started
Creating windows from 5 files...
[0/5] Creating windows from files...
[1/5] Creating windows from files...
[5/5] Creating windows from files...
 
[   1/2082] Resampling windows...
[2082/2082] Resampling windows...
Resampled 2082 windows

Created 2082 windows: faucet : 893, noise: 1189

Creating features
Traceback (most recent call last):
  File "/home/create_features.py", line 73, in <module>
    axes, freq, frame_length=0.02, frame_stride=0.01, num_filters=40, fft_length=256, low_frequency=300, high_frequency=None, win_size=101, noise_floor_db=-52)
  File "/home/dsp.py", line 58, in generate_features
    low_frequency=low_frequency, high_frequency=high_frequency)
  File "/home/../third_party/speechpy/feature.py", line 224, in mfe
    high_frequency)
  File "/home/../third_party/speechpy/feature.py", line 99, in filterbanks
    z = np.linspace(left, right, num=right - left + 1)
  File "<__array_function__ internals>", line 6, in linspace
  File "/usr/local/lib/python3.7/dist-packages/numpy/core/function_base.py", line 130, in linspace
    raise ValueError("Number of samples, %s, must be non-negative." % num)
ValueError: Number of samples, -369, must be non-negative.
Application exited with code 1

Job failed (see above)

Hi @Raunak-Singh-Invento,

Using the data forwarder, there is a 5sec max sample length. In the video, we use the edge-impulse-daemon for boards we officially support. The max length can vary based on memory available on the different targets.

For your second question, the data forwarder is great for low frequency data. Audio is high frequency and would lead to unstable results/loss in data transfer as the serial communication is too slow for real-time transfer. I would suggest capturing audio using a different device (or phone/computer) to create your dataset.

You can also reach out to Seeed on their forum as this is a community board maintained by Seeed.

Aurelien

@aurel Thanks for the reply. I will try to use my computer to record the data.

But when deploying the model, will the Wio Terminal’s microphone be able to match the frequency of the audio data collected from the computer. Won’t I experience a drop in accuracy as the model (trained on high frequency) won’t be as good at classifying the microphone’s low frequency output?

Hi @Raunak-Singh-Invento,

I’ve had no issues using my smartphone or computer to record samples for a keyword spotting trained on Edge Impulse. After you capture your samples for training, you will want to resample them to 16 kHz so that they match the sampling frequency of the Wio Terminal. I have a demo script here (https://github.com/ShawnHymel/ei-keyword-spotting/blob/master/ei-audio-dataset-curation.ipynb) that shows you how to do that (along with performing data augmentation to mix in noise and other samples).

That same repository also has an example of doing continuous keyword spotting with the Wio Terminal, if you are interested: https://github.com/ShawnHymel/ei-keyword-spotting/blob/master/embedded-demos/arduino/wio-terminal/wio-terminal.ino

Hope that helps!

1 Like

@Raunak-Singh-Invento,

Some additional info, the firmware provided by Seeed actually supports audio acquisition through our serial-daemon (so you don’t need to use the data forwarder). You can download the firmware from their documentation here.

Aurelien

@shawn_edgeimpulse In Audacity, the recording software you mentioned in the tutorial, you can already set the Project Rate to 16000 Hz. Do I still need to resample the audio with the dataset curation script or can I directly upload it to Edge Impulse.

Hi @Raunak-Singh-Invento,

You’re welcome to use Audacity to change the sampling rate. The script I linked uses librosa to resample any audio files it opens during the mixing process to the desired sampling rate (given by the SAMPLE_RATE parameter).