Script to Change Pronunciations on Mac

Create a file say.sh and enter the following:

#!/usr/bin/env bash
TEXT="$@"
while read line ; do
    TEXT="$( echo $TEXT | sed "s${line}g" )"
done < "/path/to/rules.txt"
/usr/bin/say $TEXT

Make this file executable from the command line by running chmod +x say.sh


Create a file rules.txt where you specified in the above script (4th line) and enter substitution rules like the following:

|one thing|other thing|
|foo|Apple|
|Apple Mac|Apple Macintosh|

The order of rules is important, as they are applied in order.

Run as /path/to/say.sh foo Mac to have your Mac say "Apple Macintosh"