Getting speaker Phat to work from python


So I’ve got as far as being able to play a .wav file from the command line, but I need to be able to play from within a Python program and so far have been unsuccessful.
I tried to find out if the alsa module was loaded with Help (“modules”) and got back a message that said
Automation Phat detected
and nothing else.
In the meantime I noticed that the speaker was very hot. I note that this has already been raised as a problem, but is there a solution?
So, how do I find out if alsa is loaded and if so, why doesn’t it work?


The issue with help("modules") is something I’ve been carefully rolling out fixes for. The fix for Automation HAT should be available within a few days via apt update && apt upgrade

You will probably have more luck using something like PyGame to play sound files:

Here’s an example of PyGame being used to create a drum pad and trigger:


Thanks, I’ll look out for the update.

I’ve worked out that using alsa from within python won’t work for me, so I tried pygame.
Works a treat.