Phonetic Transcription Python Arpabet

Is there a library in python that can convert words (mostly names) to Arpabet phonetic transcription?

BARBELS → B AA1 RB AH0 LZ

BARBEQUE → B AA1 RB IH0 KY UW2

BARBEQUED → B AA1 RB IH0 KY UW2 D

BARBEQUEING → B AA1 RB IH0 KY UW2 IH0 NG

BARBEQUES → B AA1 RB IH0 KY UW2 Z

+5
source share
4 answers

What you want is called the letter-to-sound or grapheme-to-phoneme movement. There are several around, including one in each text-to-speech system.

, espeak. arpabet ( ), IPA arpabet.

>>> from subprocess import check_output
>>> print check_output(["espeak", "-q", "--ipa",
                        '-v', 'en-us',
                        'hello  world']).decode('utf-8')
həlˈoʊ wˈɜːld

-x, --ipa ( ascii):

>>> check_output(["espeak", "-q", "-x", '-v', 'en-us', 'hello world'])
h@l'oU w'3:ld

arpabet , ; , "tʃ" "CH", "T SH", ( , , , "swɛtʃɑːp" "sweatshop" ).

+9

nltk cmudict:

arpabet = nltk.corpus.cmudict.dict()
for word in ('barbels', 'barbeque', 'barbequed', 'barbequeing', 'barbeques'):
    print(arpabet[word])

[['B', 'AA1', 'R', 'B', 'AH0', 'L', 'Z']]
[['B', 'AA1', 'R', 'B', 'IH0', 'K', 'Y', 'UW2']]
[['B', 'AA1', 'R', 'B', 'IH0', 'K', 'Y', 'UW2', 'D']]
[['B', 'AA1', 'R', 'B', 'IH0', 'K', 'Y', 'UW2', 'IH0', 'NG']]
[['B', 'AA1', 'R', 'B', 'IH0', 'K', 'Y', 'UW2', 'Z']]

cmudict python:

>>> import nltk
>>> nltk.download()
Use GUI to install 
corpora>cmudict
+8

cmu, nltk, arpabet

>>> entries = nltk.corpus.cmudict.entries()
>>> len(entries)
127012
>>> for entry in entries[39943:39951]:
...     print entry
...
('fir', ['F', 'ER1'])
('fire', ['F', 'AY1', 'ER0'])
('fire', ['F', 'AY1', 'R'])
('firearm', ['F', 'AY1', 'ER0', 'AA2', 'R', 'M'])
('firearm', ['F', 'AY1', 'R', 'AA2', 'R', 'M'])
('firearms', ['F', 'AY1', 'ER0', 'AA2', 'R', 'M', 'Z'])
('firearms', ['F', 'AY1', 'R', 'AA2', 'R', 'M', 'Z'])
('fireball', ['F', 'AY1', 'ER0', 'B', 'AO2', 'L'])
+5

, . espeak ( IPA), , CMU, ARPABet, IPA, :

$ listener-arpa 
we are testing
we
        W IY
are
        ER
        AA
testing
        T EH S T IH NG

This leads to exact matches in the CMU dictionary in about 45% of cases (I got about 36% using documented correspondence in CMU / Wikipedia), producing an average of 3 matches per word (on average). However, we see a “close match” about 99% of the time, that is, although we cannot exactly match the manually marked word, we usually turn off just a few phonemes.

$ sudo apt-get install espeak
$ pip install -e git+https://github.com/mcfletch/listener.git#egg=listener
+3
source

All Articles