Problem importing AudioImpulseRunner

I trained a model to detect keywords.
Now I am trying to deplyo the eim fie in my Raspberry py.
At first I went for the example code.
In the script of in Eamples folder, when it tries to execute

from import AudioImpulseRunner

This Error Occurs

Traceback (most recent call last):
  File "/home/pi/linux-sdk-python/examples/audio/", line 5, in <module>
    from import AudioImpulseRunner
  File "/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/", line 3, in <module>
    from edge_impulse_linux import image
  File "/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/", line 4, in <module>
    import cv2
  File "/home/pi/.local/lib/python3.9/site-packages/cv2/", line 5, in <module>
    from .cv2 import *
ImportError: cannot open shared object file: No such file or directory

What should be the solution?

Hi @Hasib,

This seems related to OpenCV. Can you run the following command to check which version you have installed?

pip list | grep opencv


This is version

Yes. I am really confused about why the audio classifier is using openCV. But for the time being I am really trying hard to run my eim file to run on my raspberry pi with the python SDK. this error is killing me :frowning:

Do you have any suggestion now?

This is strange, maybe reinstalling opencv would fix it.
In the meantime, you can edit the file /home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/

and comment the line:

#from edge_impulse_linux import image


1 Like

Thanks a lot Aurel.
This dismissed the error.

And then the python script “classify.pi” ran successfully. It just ran and ended. nothing happened.

I am really confused how this is hoing to use my .eim file that was downloaded as my ML model that can extract audio feature. And I found nowhere to address mi mic to the script. And so does the script “” in the /linux-sdk-python/edge_impulse_linux directory.

Can you please give a short guideline on how I can access my mic, record audio and find whether the keywords are being detected with a python script?? The reference links on the edge impulse making me move round and round within a sum of pages that says similar things over and again.

You need to provide the .eim file as a parameter:
python modelfile.eim

The script will then detect the different microphones and you’ll just need to select the one you want to use.


1 Like

It is great!
You are such a genius !

Btw, Currently I got 2 USB mics connected with my RPi as you can see in the ScreenShot.

It is considering both of them as non compatible. :frowning:

What could be the case do you think?

I general scenario, both of those mics are functioning.

Again, thanks in advance :smiley:

Hi @Hasib,

Does it work using edge-impulse-linux-runner command?


Yes it does.
When I get connected to the edge impulse account over the internet and run the classifier from it’s cloud, it works fine with a very good accuracy.

But now, when I am trying to use the .eim file offline, it says the the audio device is not compatible. Though it detects them successfully.

The Python SDK uses PyAudio and it seems the audio format provided by your mics is not supported.

To investigate more, could you provide me your project ID used to generate the .eim file?

Also, if you can edit the /home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/ file, and add the following print statement in the listAvailableDevices(self) function:

for i in range (0,numdevices):
            print(self.interface.get_device_info_by_index(i)) # <- add this line
            if self.interface.get_device_info_by_host_api_device_index(0,i).get('maxInputChannels')>0:
                input_devices.append((i, self.interface.get_device_info_by_host_api_device_index(0,i).get('name')))

From there we can check the parameters of your modelfile with PyAudio capabilities.


Of course, why not!
My project ID is 72779.
Here I used google speech command dataset to train few keyword with almost all the default settings.

And, I will let you know after I add those lines. A very big download is currently happening. I will come up with that result asap.

So here is the result after I added the print line.

I hope you are still there to help :smiley:
I also checked the edge-impulse-linux-runner command again and it works fine with both of my mics.

Hi @Hasib,

Your project works fine with my Rasp Pi and Mic. For some reason the pyaudio library doesn’t support your mic. We can dig a bit deeper to see if this is link to the sampling rate or bit width, here’s what you can change in the same file (checkDeviceModelCompatiblity function):

            supported = self.interface.is_format_supported(self.rate,
        except Exception as e: # <- change this line
            print(e) # <- add the print
            supported = False

This should give you a more detailed error with a PortAudio error. You can also remove the print statement from my last message.

Sorry for all the back and forth debug, it’s a big harder without access to the hardware :slight_smile:.