Skip to content

How to play a sound from the macOS command line

New Course Coming Soon:

Get Really Good at Git

Use the afplay built-in command:

afplay file.mp3

Here are some more options from tldr.sh

afplay

  Command-line audio player.
  More information: https://ss64.com/osx/afplay.html.

  - Play a sound file (waits until playback ends):
    afplay path/to/file

  - 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 command

say "test"

say -v Fred "Isn't it nice to have a computer that will talk to you?"
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!

Here is how can I help you: