Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install portaudio on pi properly

I am working on a project that involves recording from a mic on a raspberry pi. for now i am getting this error while the program is running.

python3: src/hostapi/alsa/pa_linux_alsa.c:3641: PaAlsaStreamComponent_BeginPolling: Assertion `ret == self->nfds' failed. Aborted

while searching for ways to fix this, i figured out the file pa_linux_alsa.c belongs to port audio. please refer to the following links.

modified pa_linux_alsa.c i think

how to install port audio

download link

first link is about the error and a modified fix, still dont know where to copy and the last two are about installing portaudio. apparently there is no easier way to install this with a command.

i downloaded the pa_snapshot enhanced version of it. but i dont know where i am supposed to put these files to begin to configure and make as in the readme. I copied the portaudio directory in to home/pi (in the user i think. "cd" and copied it there) then did as in the readme and rebooted the system. i dont see any changes in the error in program. i tried using the command whereis with pa_linux_alsa.c. that command also doesn't show the file or anything related to portaudio.

like image 990
Eshaka Avatar asked Nov 23 '19 09:11

Eshaka


Video Answer


1 Answers

Your first link correctly identifies a bug in portaudio, but the fix is incomplete. I forked the portaudio library and created a patch to fix this. Here are the steps to remove the portaudio package and compile the patched version from source:

sudo apt-get remove libportaudio2
sudo apt-get install libasound2-dev
git clone -b alsapatch https://github.com/gglockner/portaudio
cd portaudio
./configure && make
sudo make install
sudo ldconfig
cd ..

At this point, you should have a patched portaudio library, based on the pa_stable_v190600_20161030 tag. Finally, if you need the PyAudio package for Python, then install it using pip: sudo pip3 install pyaudio.

like image 100
Greg Glockner Avatar answered Sep 21 '22 05:09

Greg Glockner