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.

So I've been looking around on how to change how my mac says things, I have found my answer but what I need is some help with the coding. Here is what I want to do:

  • Create a list of word pairs.

  • Create a script that substitutes words in its parameter list according to your word-pairs list, and passes the modified parameter list to "/usr/bin/say".

I This is a quick copy of http://superuser.com/q/170041/106990 and I have very little coding know how and would like some help. I don't care in what language.

Any help would be really appreciated. Thanks in advanced.

share|improve this question
    
How do you want to use it? From the command line? –  Daniel Beck Nov 27 '11 at 7:34
    
possible duplicate of How can I change how OS X's 'say' pronounces a word? –  Ƭᴇcʜιᴇ007 Nov 28 '11 at 0:42

1 Answer 1

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"

share|improve this answer
    
Of course, this completely ignores e.g. word boundaries of case-insensitivity. But your question really didn't contain enough information on how to handle those. –  Daniel Beck Nov 27 '11 at 7:45
    
I want to be able to have it execute to before the normal say file so I can change pronunciation of the normal say command, if that is possible, so I could have the changes in Safari or Mail. –  user106990 Nov 28 '11 at 1:53
    
@user these applications use programming Apis internal to OS x and don't use say. You'd need to patch your operating system and that is more or less impossible. It seems you're out of luck then. –  Daniel Beck Nov 28 '11 at 7:03
    
Oh, well that is very disheartening. Not much I can do. –  user106990 Nov 29 '11 at 0:23

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.