I'm having difficulty correcting the pronunciation in the 'say' command, using 10.9.

I tried to add new pronunciations through:

System Preferences > Dictation and Speech > Open Accessibility Preferences > Open VoiceOver Utility > Speech > Pronunciation > +

After I added a new entry I tried it in both Terminal and TextEdit and neither pronounced it correctly:

$ say -v "Samantha" -f filename.txt -o audiofile.aiff

Although it did not work in TextEdit (Edit > Speech > Start Speaking), I want to be able to accomplish this in Terminal.

Does anyone have any idea of how I can go about doing this?

  • right before you go to Pronunciation, in the Voices tab instead, is Samantha the Default voice? It might be that the training only works for the default.
    – dwightk
    Apr 10 '14 at 15:16
  • Yes, 'she' is. Still can't seem to get this to work.
    – user75350
    Apr 10 '14 at 17:41

Here you go:

# read.sh <file-to-read> [name-of-voice]

textToRead=$(cat $1)

while read rep; do
        IFS=" "
        repArray=( $rep )
done < replacements.txt

if [ -z $2 ]; then
        echo "$textToRead" | say
        echo "$textToRead" | say -v $2

This shell script read replacements from replacements.txt and uses the say command to read the files content after replacing what's defined in replacements.txt.

replacements.txt: One line per replacement, <search> <replace>.

Sorry for the ugly code... I hate bash scripting.

  • 1
    This is amazing! Thank you very much for taking the time to write this!
    – user75350
    Apr 15 '14 at 20:17

According to this 2007 thread at discussions.apple.com the VoiceOver utility only fixes pronunciations in VoiceOver itself, not in text-to-speech.

So if you want to get say to correctly pronounce the words you should run a find and replace on the text file for each mis-pronounced word. There is probably a good way to do this in one step with a script, but if you just want to do it once you could:

  1. Open the file in Text Edit (or any text editor you prefer, I like Text Wrangler)
  2. Find (e.g.) "women" and replace all with "wimmen" (Located at Edit > Find > Find and Replace... in Text Edit)
  3. Move to the next word you want to correct finding and replacing all until you've corrected all the mispronunciations.
  4. Run say on the now incorrectly spelled text file.
  • Thanks. What would be the best way to do this? Would it be finding and replacing each mispronounced word using sed or is there a better way? Just out of curiosity, is there even a dictionary lookup tool available somewhere?
    – user75350
    Apr 11 '14 at 15:29
  • 1
    you could probably build up a sed command that does all the find and replace in one line and then save that as a bash script. As you find new mispronunciations you could then just edit the script.
    – dwightk
    Apr 11 '14 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .