Python Arpabet phonetic transcription

前端 未结 4 1364
天涯浪人
天涯浪人 2020-12-28 10:23

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

BARBELS -> B AA1 R B AH0 L Z

BARBEQUE -> B AA1 R B IH0

4条回答
  •  甜味超标
    2020-12-28 10:50

    Using nltk with the cmudict corpus installed:

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

    yields

    [['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']]
    

    To install the cmudict corpus in the python interpreter type:

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

提交回复
热议问题