pronounce

A library for interfacing with the CMU Pronouncing Dictionary

https://github.com/buonuomo/Text.Pronounce

Latest on Hackage:1.2.0.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Noah Goodman
Maintained by [email protected]

Text.Pronounce is a Haskell library for interfacing and CMU Pronouncing Dictionary. It is based off of Allison Parrish's python library pronouncing, and it exports much of the same functionality. The underlying data structure that I used for representing the dictionary was a Map from entries to lists of their possible phones as represented in the CMU dict. Many functions rely on access to the CMU dict and may return more than one result (more on the layout of the cmu dict later), so I decided to encompass this underlying state of the dictionary by using the ReaderT Monad Transformer with the List Monad embedded inside it.

In order to properly use this library, a basic understanding of the CMU Pronouncing Dictionary is assumed. Basically, the dictionary maps English words to their pronunciations transcribed using ARPAbet. This transcription reduces each word to a sequence of phones (vowel/consonant sounds) with stresses indicated by numbers at the ends of vowels. In addition, since some words can have multiple pronunciations, there can be multiple entries for a word:

CONSOLE  K AH0 N S OW1 L
CONSOLE(1)  K AA1 N S OW0 L

Most users need not worry about the actual syntax of the cmu dict; however, and should merely note that such an entry in the CMUdict would consist of the mapping from the Entry "CONSOLE" to some [Phones], a list of possible sequences of phones for this word (stresses included). For a better description of the actual cmu pronouncing dictionary, I recommend visiting the official website or simply looking through the cmu dict itself.

When working with this library, the default setting is to load the dictionary from an included binary file, but the user has the option to parse the dictionary from a unicode text file, or encode the text file into binary themselves. For this last purpose, I included the script I originally used to encode the dictionary into a binary in the examples folder.

Finally, I would like to note that Text.Pronounce.ParseDict operates on utf8 encoded files, due to compatibility with Text, which is utf encoded, despite the fact the original CMU Pronouncing Dictionary uses latin1 encoding. Because of this, if the user wants to use a version of the CMU Dictionary other than the included one, they must change to encoding to utf before parsing.