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 classify.py in Eamples folder, when it tries to execute
from edge_impulse_linux.audio import AudioImpulseRunner
This Error Occurs
Traceback (most recent call last):
File "/home/pi/linux-sdk-python/examples/audio/classify.py", line 5, in <module>
from edge_impulse_linux.audio import AudioImpulseRunner
File "/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/_init_.py", line 3, in <module>
from edge_impulse_linux import image
File "/home/pi/.local/lib/python3.9/site-packages/edge_impulse_linux/image.py", line 4, in <module>
import cv2
File "/home/pi/.local/lib/python3.9/site-packages/cv2/_init_.py", line 5, in <module>
from .cv2 import *
ImportError: libIlmImf-2_5.so.25: cannot open shared object file: No such file or directory
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
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/_init_.py
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 “audio.py” 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.
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/audio.py 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.
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 audio.py file (checkDeviceModelCompatiblity function):
try:
supported = self.interface.is_format_supported(self.rate,
input_device=device_id,
input_channels=self.channels,
input_format=pyaudio.paInt16)
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 .