brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: say makes your Mac read text aloud or save it as an audio file

Terminal
~/tips/tip-macos-say-text-to-speech

say -v '?'

Reads text out loud with a system voice, or writes the speech to an audio file.

The say command is the Mac’s built-in text-to-speech, and it is more useful than a party trick. A long command that takes ten minutes can announce when it is done.

say -v '?'
say -v Alex "The backup is finished"
say -o note.aiff -f note.txt

-v '?' lists the installed voices. -v with a voice name picks one, -r sets the speed in words per minute and -f reads the text from a file. -o writes the speech to an audio file instead of playing it. The man page lists AIFF as the default, and other formats are available with extra options.

For long jobs, chain it after the command:

rsync -a ~/Documents /Volumes/Backup/ && say "Backup done"

The && means it only speaks when the command succeeded. Use ; if you want to hear it either way.

The caveat is the voices. Which ones are available depends on the macOS version and on what you downloaded in System Settings. A voice has to be installed before -v can use it. And an MP3 is not a direct output format, so convert the audio file afterwards if you need one.

Further reading: say(1) manual

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link