0

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".

This is a quick copy of https://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.

Wenfang Du
  • 549
  • 6
  • 16

1 Answers1

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"

Daniel Beck
  • 109,300
  • 14
  • 287
  • 334
  • 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 07: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 01: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 07:03
  • Oh, well that is very disheartening. Not much I can do. – user106990 Nov 29 '11 at 00:23