Ham provides functionality on top of the CMU Pronouncing Dictionary (http://www.speech.cs.cmu.edu/cgi-bin/cmudict), to manipulate words and pronunciations.
I promised myself that I would name my first open source project “Ham”.
This is an overview. Full API docs can be found here.
Ham is a toolkit for manipulating words, pronunciations, and phonemes.
A wrapper around a list of phonemes.
Return the first index of value, starting at the start index given.
If an unstressed vowel is given, will return the first index with that vowel sound regardless of stress. Otherwise index will only find a vowel sound with identical stress.
>>> Pronunciation(['B', 'AA1', 'R', 'N']).index('AA')
1
A SoundPairing is for mapping a word with a pronunciation. It is used as an intermediate step for breaking a word into its phonograms.
Encapsulates a word.
Return and remove a letter or sequence of letters.
>>> hello = Word('hello')
>>> hello.pop('el')
'el'
>>> str(hello)
'h..lo'
If seq does not exist, raise a ValueError.
Returns a list of Pronunciations for the word.
Looks the word up in the CMU pronouncing dictionary (http://www.speech.cs.cmu.edu/cgi-bin/cmudict)
If the word does not exist in the pronouncing dictionary, return an empty list.
>>> Word('hungry').pronunciations()
[<Pronunciation "HH AH1 NG G R IY0">]
>>> Word('chewbacca').pronunciations()
[]
Generator that yields consecutive groups of vowels.
>>> list(Word('onomatopoeia').vowel_groups())
['o', 'o', 'a', 'o', 'oeia']