promo.morph_utils.utils API documentation

# promo.morph_utils.utils

Created on Apr 2, 2015

@author: tmahrt

View Source

     1"""
     2Created on Apr 2, 2015
     3
     4@author: tmahrt
     5"""
     6
     7import os
     8
     9from praatio import textgrid
    10
    11
    12def getIntervals(fn, tierName, filterFunc=None, includeUnlabeledRegions=False):
    13    """
    14    Get information about the 'extract' tier, used by several merge scripts
    15    """
    16
    17    tg = textgrid.openTextgrid(fn, includeEmptyIntervals=includeUnlabeledRegions)
    18
    19    tier = tg.getTier(tierName)
    20
    21    entries = tier.entries
    22    if filterFunc is not None:
    23        entries = [entry for entry in entries if filterFunc(entry)]
    24
    25    return entries
    26
    27
    28def makeDir(path):
    29    if not os.path.exists(path):
    30        os.mkdir(path)
    31
    32
    33def generateStepList(numSteps, includeZero=False):
    34    assert numSteps > 0
    35
    36    stepList = []
    37    if includeZero:
    38        stepList.append(0)
    39
    40    for i in range(numSteps):
    41        stepList.append((i + 1) / float((numSteps)))
    42
    43    return stepList

def getIntervals(fn, tierName, filterFunc=None, includeUnlabeledRegions=False): View Source

    13def getIntervals(fn, tierName, filterFunc=None, includeUnlabeledRegions=False):
    14    """
    15    Get information about the 'extract' tier, used by several merge scripts
    16    """
    17
    18    tg = textgrid.openTextgrid(fn, includeEmptyIntervals=includeUnlabeledRegions)
    19
    20    tier = tg.getTier(tierName)
    21
    22    entries = tier.entries
    23    if filterFunc is not None:
    24        entries = [entry for entry in entries if filterFunc(entry)]
    25
    26    return entries

Get information about the 'extract' tier, used by several merge scripts

def makeDir(path): View Source

    29def makeDir(path):
    30    if not os.path.exists(path):
    31        os.mkdir(path)

def generateStepList(numSteps, includeZero=False): View Source

    34def generateStepList(numSteps, includeZero=False):
    35    assert numSteps > 0
    36
    37    stepList = []
    38    if includeZero:
    39        stepList.append(0)
    40
    41    for i in range(numSteps):
    42        stepList.append((i + 1) / float((numSteps)))
    43
    44    return stepList