I have built a simple docker image and am trying to figure out why PyAudio will not output any sound.
speaker-test
outputs pink noise to the headphone jack.aplay sound.wav
also workspython3 play_wave.py sound.wav
hangs and doesn't output any sound.
play_wave.py
is an example/test program included with the pyaudio package.
I setup this test repository so you can witness the exact behavior: https://github.com/PaulWieland/pyaudio_test
git clone https://github.com/PaulWieland/pyaudio_test.git
cd pyaudio_test
docker build -t paulwieland/pyaudio_test .
docker run -it --rm --device /dev/snd paulwieland/pyaudio_test /bin/sh
Once inside the container, run aplay Front_Center.wav
- the audio is played through the raspberry Pi's headphone jack.
Now run python3 play.py Front_Center.wav
In my case the script hangs and never finishes. I may get a blip of audio after a few minutes but it will not play the sound correctly.
EDIT:
This issue is some sort of compatibility problem with PortAudio running on a Raspberry Pi 4 using the latest Raspbian OS.
I'm now convinced it has nothing to do with Docker or Python, because I cannot get a simple C program which plays a wav using portaudio to work either.