8

I have about 200 lines of Beowulf which a few friends of mine and I rendered into International Phonetic Alphabet about a year and a half ago. At the time, one of the tools we used to check the pronunciations back was OS X's say command.

Here's the first six lines according to the Klaeber edition of the poem converted into IPA, which I know for certain say can read out properly, because I've run it myself on the MacBook from which I am typing this very question:

hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum
ˈðeːodˌkyniŋɡɑ θrymː jeˈfruːnon
huː ðɑ æðelɪŋɡɑs ˈelːen ˈfremːedon!
oft ʃyld ʃefiŋ ˈʃæɑðenɑ θræːɑtum,
ˈmɑniɣum mæjθum ˈmeːodusetlə ovˈtæːax,
'ejzudə eːorɑs, syðːɑnærest wæːɑrð

Now, try as I might, I can not get it to read out any of the above lines properly any more. I've tried all of the English-speaking voices (pre 10.5 voices are hilarious), but the voices I am sure worked before, such as Fiona and Kate, now seem to ignore the IPA characters completely.

These are the somewhat un-DRY-y test commands I've used this time around:

say --rate=150 --voice=Fiona "/hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum/"
say --voice=Fiona "/hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum/"
say --rate=150 --voice=Fiona "hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum"
say --voice=Fiona "hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum"
say --voice=Fiona hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum
say --voice=Fiona /hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum/

But they all skip over the IPA characters entirely except for æ, which is sometimes pronounced. ɣ certainly never makes it into the synthesis any more, which it definitely did last time.

Am I missing something, or is it possible that for some reason they removed the IPA feature in a recent update? I'm pretty sure it was Mavericks that we were using, but it could've been Snow Leopard.

2
  • Guessing references to World War II quotes are frowned upon in questions, @ncdownpat. ;) Sep 21, 2014 at 3:23
  • I've been thinking about this a bit more, and I did blank my laptop and re-install OS X from scratch at the beginning of this year. I suppose it's possible that there was something in Leopard or Snow Leopard which supported this feature which has been removed in a later version, like X11 was removed between 10.6 and 10.7. Would be a shame, though. It's starting to look like I may be better off writing my own hooks into the TTS engine to speak Old English. :/ Sep 21, 2014 at 23:10

3 Answers 3

9

Here's a Ruby script that takes a string of Unicode IPA text and converts it to OS X's say command phonetic syntax.

Slap this Ruby code into a file—let's call it ipa2say.rb. Make the file executable (i.e. chmod u+x ipa2say.rb). Execute the executable, piping some IPA text to it. Out will come some ASCII phonetic text.

Then run say with the [[inpt PHON]] directive.

So, an example. Let's say you want to say the IPA text "ˌɪntərˈnæʃənəl fəˈnɛtɪk ˈælfəˌbɛt fəˈrɛvər". From the command line:

echo "ˌɪntərˈnæʃənəl fəˈnɛtɪk ˈælfəˌbɛt fəˈrɛvər" | ./ipa2say.rb

It will spit out:

IXntrnAESnl fAXnEHtIXk AElfbEHt frEHvr

You then run: say "[[inpt PHON]]IXntrnAESnl fAXnEHtIXk AElfbEHt frEHvr"

Here's the script.

#!/usr/bin/ruby -w

map =   {       'æ' => 'AE',
                'eɪ' => 'EY',
                'ɑ' => 'AO',
                'əˈ' => 'AX',
                'i' => 'IY',
                'ɛ' => 'EH',
                'ɪ' => 'IH',
                'aɪ' => 'AY',
                'ɪ' => 'IX',
                'ɑ' => 'AA',
                'u' => 'UW',
                'ʊ' => 'UH',
                'ʌ' => 'UX',
                'oʊ' => 'OW',
                'aʊ' => 'AW',
                'ɔɪ' => 'OY',
                'b' => 'b',
                'ʧ' => 'C',
                'd' => 'd',
                'ð' => 'D',
                'f' => 'f',
                'g' => 'g',
                'h' => 'h',
                'ʤ' => 'J',
                'k' => 'k',
                'l' => 'l',
                'm' => 'm',
                'n' => 'n',
                'ŋ' => 'N',
                'p' => 'p',
                'r' => 'r',
                's' => 's',
                'ʃ' => 'S',
                't' => 't',
                'θ' => 'T',
                'v' => 'v',
                'w' => 'w',
                'j' => 'y',
                'z' => 'z',
                'ʒ' => 'Z',
                'ɜ' => '',
                ' ' => ' ',
                'ˈ' => ''
        }

text = ARGF.read

substring = ''

text.split("").each do |c|

    substring << c

    if substring.length == 2
        if map.has_key? substring
            print map[ substring ]
        else
            front = substring[0]
            if map.has_key? front
                print map[ front ]
            end
            back = substring[1]
            if map.has_key? back
                print map[ back ]
            end
        end

        substring = ''
    end
end
4
  • 5
    This is awesome, although it's worth noting that [[inpt PHON]] is only supported on voices which were in OS X prior to 10.6. It's mildly annoying, as they're much lower quality than the modern voices, and it would be nice to be able to feed the data into Fiona, for instance. Oh well! Mar 11, 2015 at 18:33
  • Yeah it doesn't work with the newer voices.
    – adib
    Aug 14, 2015 at 7:29
  • I found this list of the pre-10.6 voices: alvinalexander.com/blog/post/mac-os-x/… The non-gimmicky ones are: Agnes, Kathy, Princess, Vicki, Victoria, Bruce, Fred, Junior, Ralph. I've not checked which of those actually works with IPA yet.
    – tobych
    May 9, 2016 at 23:17
  • As Christopher's answer points out, the say command no longer interprets [[inpt PHON]] correctly, meaning there's no longer any built-in solution to speak IPA via command line.
    – kalanchloe
    Mar 31, 2021 at 18:41
4

Just wanted to add that IPA pronunciation has seemingly been moved to VoiceOver, which is now, I guess, a completely different TTS engine. Going to VoiceOver Utility, Speech, then Pronunciation allows customization with IPA. This has absolutely no effect on "say" and the "Edit, Speech, Start Speaking" command, tho—ugh!

VoiceOver Utility Application, Speech Options, Pronunciation Tab showing IPA listings for over-ridden pronunciations.

1
  • Ah, cheers! Thanks for letting me know, I'll have a dig into it at some point to see whether it's possible to trigger VO with text from the CLI. ^^ Feb 4, 2021 at 15:06
2

Try brackets/slashes around each word if it doesn't work with a phrase. This doesn't work:

say "/hwæt we ˈɡɑːrˌdenɑ in ˈjæːɑrdɑɣum/"

But this seems to:

say "/hwæt/ /we/ /ˈɡɑːrˌdenɑ/ /in/ /ˈjæːɑrdɑɣum/"

Square brackets work also:

say "[huː] [ðɑ] [æðelɪŋɡɑs] [ˈelːen] [ˈfremːedon]"

Good luck!

(Edited because I re-read and saw that you tried the slashes surrounding the whole phrase.)

1
  • 1
    Hmm… I'm not sure it's actually reading it as IPA. It sounds like it's skipping all the non-English characters when I run those commands. If I do say -v Alex "/hwæt/ /we/ /ˈɡɑːrˌdenɑ/ /in/ /ˈjæːɑrdɑɣum/", it says "Weh wiardena yeardaou" >.< Thanks for trying, though. :) Oct 22, 2015 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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