# Find a word's linguistic pronunciation

Is there a way to get a word's linguistic pronunciation given the word as a string?

I would like a function LingusticPronunciation such that, for example, LingusticPronunciation["Dog"] would return "Dawg" or maybe even "dȯg" or "däg", depending on what type of pronunciation dictionary is used.

Ultimately I am trying to search for all homophones in a document and would prefer not having to use the internet to check for different homophone/pronunciation information.

-
For the edit, don't use caps: WordData["smith","PhoneticForm"] –  ssch Sep 11 '13 at 20:11

WordData can give you the IPA form of a word:

Gather[
WordData[#, "PhoneticForm"] & /@ {"pray", "prey", "wade", "weighed"}
]
(* {{"pr'ey", "pr'ey"}, {"w'eyd", "w'eyd"}} *)


EDIT It seems WordData[word, "PhoneticForm"] no longer provides the proper IPA, however that data is still included in the paclet so we can make a new WordData property for that. (or override the the current PhoneticForm)

The IPA data is stored in a file called "IPAPronunciation.wdx" which contains a dispatch table with the "word"->"ipa" rules. It does not contain a _ -> Missing["NotAvailable"] so that is added.

Module[{
ipapath = FileNames@FileNameJoin[
{$UserBasePacletsDirectory,(*$ avoid SE indentation bug *)
"Repository", "WordData_IPAPronunciation-*", "Data", "IPAPronunciation.wdx"}],
iparules},
ipapath == {} || ! FileExistsQ[Last@ipapath],
Return[\$Failed, Module]];
iparules = Dispatch[Append[
Import[Last@ipapath][[2, 1]],
_ -> Missing["NotAvailable"]]];
Unprotect[WordData];
WordData[word_String, "IPA"] := word /. iparules;
DownValues[WordData] = RotateRight[DownValues[WordData]];
Protect[WordData];
]
WordData[#, "IPA"] & /@ {"pray", "prey", "wade", "weighed"}
(* {"prˈeɪ", "prˈeɪ", "wˈeɪd", "wˈeɪd"} *)


Some things used in above code:

If there is a neat way to add a rule to a dispatch table without redoing the Dispatch call feel free to edit.
Do you know of any way to get this to work approximately for different names? Smith, Williams, Johnson, Brees WordData["Smith","PhoneticForm"] –  Liam William Sep 11 '13 at 20:06
That is a very interesting link. It appears the following works for names WordData[ToLowerCase@"Smith", "PhoneticForm"] although I am not sure how accurate it is. –  Liam William Sep 11 '13 at 20:12