Skip to content

Converting between Alphabets

To convert between phonetic alphabets, the phonecodes package has been integrated in phones. This currently supports arpabet, ipa, xsampa, disc and callhome.

Using Converter

You can use the Converter object below to convert a string of phones to a list of phones in a different alphabet.

In [1]:
from phones.convert import Converter
converter = Converter()
In [2]:
converter("HH EH L OW", "arpabet", "ipa")
Out[2]:
['h', 'ɛ', 'l', 'oʊ']

We can also convert to a string.

In [3]:
converter("HH EH L OW", "arpabet", "ipa", return_str=True)
Out[3]:
'h ɛ l oʊ'

And show all possible formats.

In [4]:
converter.formats
Out[4]:
['disc', 'xsampa', 'ipa', 'callhome', 'arpabet']