English text to Arpabet

 python cmudict  phonetic transcription 

 Got this code somewhere online.

Wanted to learn the pronunciations for english words

import nltk
nltk.download('cmudict')

arpabet = nltk.corpus.cmudict.dict()

for word in ("bbc", "modern"):
try:
print(arpabet[word])
except Exception as e:
print("error")

output:
[nltk_data] Downloading package cmudict to /root/nltk_data... [nltk_data] Package cmudict is already up-to-date! [['B', 'IY2', 'B', 'IY0', 'S', 'IY1']] [['M', 'AA1', 'D', 'ER0', 'N']]

Comments