Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

OS X's say command is useful for some tasks (such as Skype's 'notify me when a contact comes online), but it is pronouncing some names incorrectly. Is there a way to teach say to pronounce a word differently?

For example, try:

say "Hi, Joel Spolsky"

The 'ol' sounds like 'ball' rather than 'old'. I'd like to add an exception that say "Pronounce Spolsky like this", rather than try to teach new linguistic rules. I bet there is a way since it can pronounce "iphone" as Apple wants.


Update - After some research, here's what I've learned:

  1. Text-to-speech is split between turning the text to phonemes, and then the phonemes are turned into audio using a voice. Changing the voice doesn't effect the phonemes.
  2. The Speech Synthesis Manager has some functions for turning text to phonemes, and a method for registering a speech dictionary that will add new text-phoneme maps. However, Apple's speech dictionary must be in a binary form - I didn't find any plist XML.
  3. Using dtrace while running say, I found some interesting files opened in /System/Library/PrivateFrameworks/SpeechDictionary.framework/Resources. This is probably the speech dictionary, but they are all binary, except for Homophones, which is XML. Adding entries to Homophones does nothing - it is probably used in speech-to-text. They are also code signed by Apple - changing them may prevent some programs from working.
    • PrefixDictionary
    • CartNames
    • CartLite
    • SymbolDictionary
    • Homophones
  4. There are ways to add text versions of application interface elements so VoiceOver works, a lot of which a developer gets for free, but there are tricky bits. The standard here appears to be to use a phonetic spelling as needed.

My guesses are:

  1. say is a light layer of code on top of the Speech Synthesis Manager. It would be easy for the Apple devs to add a command line option to take the path to a speech dictionary plist for alternate phoneme mapping, but they didn't. It may be a useful open-source project to write a better say.
  2. Skype probably uses Speech Synthesis Manager directly, leaving no hooks to change the way my friend's names are pronounced, other than spelling them phonetically, which is silly.
  3. The easiest way to make a command line version of say is how JRobert suggested.

Here's my quick implementation, using Doug Harris's spelling suggestion:

#!/bin/sh
echo $@ | tr '[A-Z]' '[a-z]' |
sed "s/spolsky/spowlsky/g" |
/usr/bin/say

Finally, some fun command line stuff:

# Apple is weird
sqlite3 /System/Library/PrivateFrameworks/SpeechDictionary.framework/Resources/Tuples .dump
# Get too much information about what files are being opened
sudo dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'
# Just fun
say -v bad "Joel Spolsky Spolsky Spolsky Spolsky Spolsky, Joel Spolsky Spolsky Spolsky Spolsky Spolsky"
echo "scale=1000; 4*a(1)" | bc -l | say
share|improve this question
    
Did you try changing the voice say is using with -v ? –  Studer Jul 30 '10 at 20:07
2  
No effect on pronunciation: say -v alex 'Spolsky' ; say -v vicki 'Spolsky'; say -v bad 'Spolsky Spolsky Spolsky Spolsky Spolsky Spols'. The list of voices can be found at System Preferences -> Speech -> Text to Speech. The problem is at phoneme translation, not at voice synthesis. If you are calling the library directly, you can set custom phonemes: developer.apple.com/mac/library/documentation/Carbon/Reference/… Searching my disk to see if the Apple devs used a .plist ... –  jwhitlock Jul 30 '10 at 21:09

6 Answers 6

up vote 8 down vote accepted

Well you can also input the exactly phonemes you want to be said. The syntaxe is not so complicated.

Ex:

[[inpt PHON]] hAAIH.

Check this link to learn more: http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/Phonemes/Phonemes.html#//apple_ref/doc/uid/TP40004365-CH9-SW1

share|improve this answer
1  
You can use Repeat After Me to generate the phonetic syntax. It's available from developer.apple.com/downloads. –  ؘؘؘؘ Sep 9 '12 at 9:00
    
Repeat After Me is part of Auxiliary Tools for Xcode. –  Daniel Beck Dec 24 '12 at 21:00
    
This worked for me: say 'Hi, Joel [[inpt PHON]]spOWl skIY.' I wonder if this plus phonetic fields in Address book will do the trick: macdailynews.com/2011/10/20/… –  jwhitlock Jan 9 '13 at 4:18

I don't think you can. You could try setting the default voice to a different one in system preferences, or you could type how you want things to be pronounced. For example, "Hi, Jole Spole sky."

share|improve this answer
1  
how about "Spowlsky"? –  Doug Harris Jul 30 '10 at 18:53

There's no way to 'teach' the say program to pronounce words differently. As suggested above, the easiest way to get the pronunciation you want is to adjust the spelling of your words until it says them the way you want.

share|improve this answer
  • Create a list of word pairs [spolsky spowlsky; joel jole; ...].
  • Create a script in your favorite scripting language that substitutes words in its parameter list according to your word-pairs list, and passes the modified parameter list to "/usr/bin/say".
  • Make the script executable, call it "say" and put it in a folder that appears earlier in your $PATH than does "/usr/bin".
  • Add spelling variants to your word-pairs list as you find more words you'd like pronounced differently.

Your new say will work like the old say, but with your preferred pronunciation.

share|improve this answer

This is an unfortunate limitation, given that Apple seems to be most of the way there. Users of VoiceOver can easily insert their own pronunciations using the VoiceOver Utility (Speech->Pronunciation). But, VoiceOver settings don't seem to apply to "say" command or the Edit->Speech->"Start Speech" menu in Safari and other Apple-provided applications.

share|improve this answer

@bruno-carvalho's answer answered this question for me. But, I also needed to hunt down the tag [[inpt TEXT]] to get the say command to return to reading (speech synthesizing) text normally. For example:
say [[inpt PHON]] hAAIH, [[inpt TEXT]] how are you?

Hopefully, adding this to the answer will help subsequent readers of this question.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.