Files
pysle/test/syllabifyTextgrid.py
T
Tim Mahrt 5d598b1b88 INITIAL COMMIT: pysle - python interface to ISLEX dictionary
Code tested over a decent corpus.  Features:

- look up phone and syllable info for the
  canonical pronunciation of a word

- map an actual pronunciation to a dictionary
  pronunciation (can be used to automatically find
  speech errors)

- automatically syllabify a textgrid containing words
  and phones (e.g. force-aligned text)
2014-10-23 15:13:07 -05:00

37 lines
1013 B
Python

'''
Created on Oct 22, 2014
@author: tmahrt
This example was originally meant to show how you can use the library
to modify a textgrid. It still shows that, but all that code is now in
the main library (pysle.praattools.syllabifyTextgrid)
This snippet shows you how to use this function.
'''
from os.path import join
import praatio
from pysle import isletool
from pysle import praattools
path = join('.', 'files')
path = "/Users/tmahrt/Dropbox/workspace/pysle/test/files"
tg = praatio.openTextGrid(join(path, "pumpkins.TextGrid"))
isleDict = isletool.LexicalTool('/Users/tmahrt/Dropbox/workspace/pysle/test/islev2.txt') # Needs the full path to the file
# Get the syllabification tiers and add it to the textgrid
syllableTG = praattools.syllabifyTextgrid(isleDict, tg, "word", "phone",
skipLabelList=["",])
tg.addTier(syllableTG.tierDict["syllable"])
tg.addTier(syllableTG.tierDict["tonic"])
tg.save(join(path, "pumpkins_with_syllables.TextGrid"))