SoundUtils { public static String arpabetToIPA(String s) throws IllegalArgumentException { String[] arpaPhonemes = s.trim().split("[ \\t]+"); StringBuffer ipaPhonemes = new StringBuffer(s.length()); for (String arpaPhoneme : arpaPhonemes) { char stressChar = arpaPhoneme.charAt(arpaPhoneme.length() - 1); if (stressChar == '0' || stressChar == '1' || stressChar == '2') { arpaPhoneme = arpaPhoneme.substring(0, arpaPhoneme.length() - 1); ipaPhonemes.append(arpabetMap.get(Character.toString(stressChar))); } String ipaPhoneme = arpabetMap.get(arpaPhoneme); if (ipaPhoneme == null) { throw new IllegalArgumentException(); } ipaPhonemes.append(ipaPhoneme); } return ipaPhonemes.toString(); }  static int differenceEncoded(String es1, String es2); static String arpabetToIPA(String s);  }
@Test public void arpabetToIPATest() throws Exception { assertEquals("ˈɛndˌɪnɚkwˈoʊt", SoundUtils.arpabetToIPA(" EH1 N D IH2 N ER0 K W OW1 T ")); }