# Raspberry Pi Zero with Speaker pHAT play recorded sounds

**URL:** <https://forum.core-electronics.com.au/t/raspberry-pi-zero-with-speaker-phat-play-recorded-sounds/7982>\
**Category:** Uncategorized\
**Created:** [9 July 2020 00:06 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-with-speaker-phat-play-recorded-sounds/7982 "2020-07-09T00:06:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart91740](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Stuart91740](https://forum.core-electronics.com.au/u/Stuart91740)\
**Post date:** [9 July 2020 00:06 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-with-speaker-phat-play-recorded-sounds/7982/1 "2020-07-09T00:06:49Z")

</div>

I am building a retirement project for a colleague and would like to put together a Speaker pHAT and Raspberry Pi Zero that plays back audio clips from a SD card when an emergency stop button is pressed. It will need to be battery powered and small enough to fit in the base of the button enclosure.

Any assistance with a parts list and pointers on what programming needs to be done would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Stuart91740](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Stuart91740](https://forum.core-electronics.com.au/u/Stuart91740)\
**Post date:** [9 July 2020 00:36 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-with-speaker-phat-play-recorded-sounds/7982/2 "2020-07-09T00:36:44Z")

</div>

Obviously need power (battery), on/off switch, audio to an internal speaker and connectivity to the “big red button”…

---

<div class="post-metadata">

**Author:** ![Owen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/owen/32/2948_2.png) [@Owen](https://forum.core-electronics.com.au/u/Owen)\
**Post date:** [10 July 2020 01:36 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-with-speaker-phat-play-recorded-sounds/7982/3 "2020-07-10T01:36:44Z")

</div>

Hey Stuart,

That sounds like a great project!

We don’t stock the Speaker pHAT anymore, so if you are looking to buy one you should check out the replacement, the [Pimoroni Pirate Audio Speaker for Raspberry Pi](https://core-electronics.com.au/pimoroni-pirate-audio-speaker-for-raspberry-pi.html). It’s perfect for making a tiny radio, sound effect player or games console!

Regarding playing audio files, I recommend the Pygame library. I may be wrong, but I believe that it is pre-installed on the Pi. You can use the Pygame Mixer Music Module to play audio files. I have included an example code below (for if you had a file named myFile.wav)O

```
import pygame
pygame.mixer.init()
pygame.mixer.music.load("myFile.wav")
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
    continue

```

For the button that will activate the sound, I’d look into the [Big Dome Push Button](https://core-electronics.com.au/big-dome-push-button-red.html). It sounds like the ideal size/shape/design for what you’re looking for!
