Linux sdk python error with the classify audio example

Hello everyone, I’m trying to run the audio classify example in the linux sdk python in a RPi4 8Gb. I’ve followed this guide (Responding to your voice - Edge Impulse Documentation) to collect data and created a dataset with 3 equally distributed classes: “Sebastian”, “unkown” and “noise”.
Then, I’ve trained the system on these data, following the same instructions mentioned before, and downloaded my eim file (edge-impulse-linux-runner --download sebastianModelFile.eim Then I ran the classy script as follows "python3 classify.py ./sebastianModelFile.eim 2`"
The result is


Loaded runner for "Al San / Sebastian"
Device ID 2 has been provided as an argument.
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_headpho.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_headpho.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib conf.c:5200:(snd_config_expand) Unknown parameters {AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2  CARD 0}
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2  CARD 0}
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1009:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:573:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dmix.c:1009:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:573:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
selected Audio device: 2
2
Traceback (most recent call last):
  File "/home/pi4-8/linux-sdk-python/examples/audio/classify.py", line 65, in <module>
    main(sys.argv[1:])
  File "/home/pi4-8/linux-sdk-python/examples/audio/classify.py", line 53, in main
    for res, audio in runner.classifier(device_id=selected_device_id):
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/audio.py", line 164, in classifier
    res = self.classify(features[:self.window_size].tolist())
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/audio.py", line 152, in classify
    return super(AudioImpulseRunner, self).classify(data)
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py", line 60, in classify
    return self.send_msg(msg)
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py", line 105, in send_msg
    raise Exception('Wrong id, expected: ' + str(ix) + ' but got ' + resp["id"])
TypeError: 'NoneType' object is not subscriptable

I would really appreciate any hint or guidance to solve this issue.

Hi @AlSan,

It looks like the script is having trouble finding your audio port. Can you try running it without specifying the device ID?

python3 classify.py ./sebastianModelFile.eim

Thank you @shawn_edgeimpulse for your reply. I’ve tried your suggestion to no avail. When not entered, the process asks to specify the audio device. I’ using respeaker 2 mic hat for raspberry pi. It works well, in fact, all the audio samples in the “Sebastian” class have been recorded with this device. I have also tried a fresh Bulleye installation (just the mic hat dependencies installed), and followed the instructions again. Still getting the same error:

Traceback (most recent call last):
  File "/home/pi4-8/linux-sdk-python/examples/audio/classify.py", line 65, in <module>
    main(sys.argv[1:])
  File "/home/pi4-8/linux-sdk-python/examples/audio/classify.py", line 53, in main
    for res, audio in runner.classifier(device_id=selected_device_id):
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/audio.py", line 164, in classifier
    res = self.classify(features[:self.window_size].tolist())
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/audio.py", line 152, in classify
    return super(AudioImpulseRunner, self).classify(data)
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py", line 60, in classify
    return self.send_msg(msg)
  File "/home/pi4-8/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py", line 105, in send_msg
    raise Exception('Wrong id, expected: ' + str(ix) + ' but got ' + resp["id"])
TypeError: 'NoneType' object is not subscriptable

I have also tried with all the other audio device options, just to see if a different error pops up, but there was no difference. Any other suggestion?
Thanks again for your time

Hi @AlSan
I tried to reproduce your issue, but using a USB camera with an embedded microphone, and it works fine. I don’t have ReSpeaker HAT, but it looks like an issue related to this particular hardware/driver hardware.
What method did you use to collect samples? Maybe our python example for classify is not handling your audio device correctly.

Best regards,
Mateusz