How to play a sound from the macOS command line
The Valley of Code
Your Web Development Manual
afplay built-in command:
Here are some more options from tldr.sh
Command-line audio player.
More information: https://ss64.com/osx/afplay.html.
- Play a sound file (waits until playback ends):
- Play a sound file at 2x speed (playback rate):
afplay --rate 2 path/to/file
- Play a sound file at half speed:
afplay --rate 0.5 path/to/file
- Play the first N seconds of a sound file:
afplay --time seconds path/to/file
You can also make your Mac talk using the
say -v Fred "Isn't it nice to have a computer that will talk to you?"