I am trying to use a USB microphone with python sound device and raspberry pi3B+. When I execute the script in the console typing $ python3 sound.py it runs and records all ok. But when I try to execute sudo python3 sound.py it returns the error:

Error opening InputStream: Invalid sample rate [PaErrorCode -9997]
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048

I need to use sudo to run my script. What can I do to solve it?

Thank you!

  • What library are you using? – user96931 Feb 19 at 1:31
  • Hello and welcome - Please add your code. Check this link out. – M. Rostami Feb 19 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.