Raspberry pi audio classification default mic issue

I am having some issues , with accessing the usb mike every time I run the edge impulse mode ,
For the first time when I connect the program it will ask me for which mike I want to use and I am able to use that mike properly ,
However after shutting down and rebooting if I tried to run it again without using edge-impulse-linux --clean command ,
It will default to HW mike and gives me PMD error , how to make the edge impulse program use the the usb mike as default every time I use it ?

Hello @vinaycs,

Which OS / device are you using? I have not seen that issue before.

Can you check that your microphone is listed in edge-impulse-config.json

cat ~/edge-impulse-config.json

It should output something like the following:

    "host": "edgeimpulse.com",
    "jwtToken": "eyXXX",
    "lastVersionCheck": 1649058554875,
    "dataForwarderDevices": {},
    "daemonDevices": {},
    "linuxProjectId": 14225,
    "audio": "HD Pro We"

Here my “HD Pro We” microphone is not the default one on my Macbook



I am running it on Rapberry pi 4 , in the headless method using putty .

Ok, let me setup a usb mic with my RPI4, I’m also using it in the headless mode through SSH.

I come back to you in a few minutes.

1 Like


:thinking: interesting.
After a reboot I am having an error too:

Edge Impulse Linux runner v1.3.5

[RUN] Already have model /home/pi/.ei-linux-runner/models/14225/v41/model.eim not downloading...
[RUN] Starting the audio classifier for Edge Impulse Inc. / Tutorial: Responding to your voice (v41)
[RUN] Parameters freq 16000Hz window length 1000ms. classes [ 'helloworld', 'noise', 'unknown' ]
[RUN] Using microphone hw:1,0
[RUN] Failed to run impulse sox exited with code 2: sox FAIL formats: can't open input  `hw:1,0': snd_pcm_open error: No such file or directory

Is it the same error as yours?

I’m digging into it.



yes, this is the same error which i am facing ,
Thank you for looking into it

@louis I am also facing a new issue right now ,
I have already created the model and built it and run it yesterday , but now i am getting this message when I try to run the model locally

Could you please look into this too

You’re having a white space between linux and -runner

What you have:
edge-impulse-linux -runner

What you should do:

1 Like

Some more info:

After a reboot, when I run again the edge-impulse-linux-runner --clean, my microphone ID changed although it is the same.

    "audio": "hw:2,0"

I’ll check if I can force it to come back to its previous ID when the RPI initialize.



1 Like

@louis and sometimes after doing this a couple of times , it defaulted into the usb microphone , without any issues , even when it was showing hw :1,0 it ran properly , not sure why

Hello @vinaycs,

Ok, I have an idea but not sure it will work in all the conditions, devices, etc…

Run the following command:

arecord -l

You should see an output looking like this:

**** List of CAPTURE Hardware Devices ****
card 3: C920 [HD Pro Webcam C920], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

If you have a close look, it shows the hw id: card 3

Now you run the following command to get the ID

arecord -l | grep "card" | cut -c 6

It will output 3 in my case.
I guess you can use sed or any other tool you are familiar with to replace your "audio": "hw:1,0" line with "audio": "hw:X,0"

Again, it’s not the cleanest way but that should fix your issue if you want to automatically select the right device after a reboot.