Luke Oliff.

TIL: Playing Audio From the Terminal With SoX Play

·TIL·1 min read·Luke Oliff

Testing TTS output means listening to a lot of audio files. Opening a media player for each one is slow. play (from SoX) plays them straight from the terminal.

play output.mp3

Plays the file through your speakers and exits when it finishes. No window, no playlist, no GUI.

play test-speech.wav repeat 2

Play a file three times. Useful for A/B comparing the same voice at different speeds without manually restarting.

play output.mp3 trim 0 5

Play only the first 5 seconds of a file. Speed up the loop of generating, listening, and tweaking parameters.

play output.mp3 vol 0.8

Reduce playback volume. Some TTS voices are louder than others and the difference distorts perception of quality.

Does play support all audio formats?

It supports whatever SoX supports. WAV, MP3, FLAC, OGG, and most common formats work. For MP3 SoX uses an external decoder library.

How do I install SoX on macOS?

brew install sox

The play command is included in the SoX package.