How to use the praatio.utilities.utils.findFiles function in praatio

To help you get started, we’ve selected a few praatio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timmahrt / praatIO / praatio / applied_scripts / sppas_util.py View on Github external
removeTierList = REMOVE_TIER_LIST
    
    if renameTierList is None:
        renameTierList = RENAME_TIER_LIST
    
    # Remove intermediate files
    if deleteIntermediateFiles is True:
        lowerTGList = utils.findFiles(tgPath, filterExt=".textgrid")
        xraList = utils.findFiles(tgPath, ".xra")
        removeList = lowerTGList + xraList
        for fn in removeList:
            os.remove(join(tgPath, fn))
    
    # Replace the textgrids input to SPPAS (suffixed with '-merge')
    # with the textgrids that SPPAS output
    tgFNList = utils.findFiles(tgPath, filterExt=".TextGrid")
    tgFNList = [fn for fn in tgFNList
                if '-merge' in fn]
    
    # Clean up the textgrids output by SPPAS
    # Rename tiers, delete tiers, and convert the phonetic tier
    # from xsampa to IPA
    for mergeFN in tgFNList:
        
        mergeName = os.path.splitext(mergeFN)[0]
        nonMergeName = mergeName.split('-merge')[0]
        if not os.path.exists(join(outputPath, nonMergeName + ".wav")):
            shutil.copy(join(tgPath, nonMergeName + ".wav"),
                        join(outputPath, nonMergeName + ".wav"))
        if os.path.exists(join(outputPath, nonMergeName + ".TextGrid")):
            print("Skipping %s -- already exists" % mergeName + ".TextGrid")
            continue
github timmahrt / praatIO / praatio / applied_scripts / sppas_util.py View on Github external
If /replaceOrigTextgrids/ is True, the input textgrids to SPPAS will be
    replaced by the textgrids SPPAS outputs
    '''
    
    if not os.path.exists(outputPath):
        os.mkdir(outputPath)
    
    if removeTierList is None:
        removeTierList = REMOVE_TIER_LIST
    
    if renameTierList is None:
        renameTierList = RENAME_TIER_LIST
    
    # Remove intermediate files
    if deleteIntermediateFiles is True:
        lowerTGList = utils.findFiles(tgPath, filterExt=".textgrid")
        xraList = utils.findFiles(tgPath, ".xra")
        removeList = lowerTGList + xraList
        for fn in removeList:
            os.remove(join(tgPath, fn))
    
    # Replace the textgrids input to SPPAS (suffixed with '-merge')
    # with the textgrids that SPPAS output
    tgFNList = utils.findFiles(tgPath, filterExt=".TextGrid")
    tgFNList = [fn for fn in tgFNList
                if '-merge' in fn]
    
    # Clean up the textgrids output by SPPAS
    # Rename tiers, delete tiers, and convert the phonetic tier
    # from xsampa to IPA
    for mergeFN in tgFNList:
github timmahrt / praatIO / praatio / applied_scripts / sppas_util.py View on Github external
sometimes makes errors (or is not configured properly by the user).  This
    script is strictly for those situations.
    
    If there are multiple audio files for each transcript, you can derive the
    transcript name using /nameMod/
    
    If there is a chance of even a slight segment of silence on the edges of
    the audio file, /addPause/ should be True.
    '''
    if nameMod is None:
        nameMod = lambda x: x

    if not os.path.exists(outputPath):
        os.mkdir(outputPath)
    
    wavList = utils.findFiles(wavPath, filterExt=".wav", stripExt=True)
    
    for wavName in wavList:
        
        transcriptName = nameMod(wavName)
        
        # Add initial and final small pauses to each transcript
        with io.open(join(txtPath, transcriptName + ".txt"), "r") as fd:
            txt = fd.read()
            
        if addPause is True:
            txt = "+ %s +" % txt.lower()

        wavFN = join(wavPath, wavName + ".wav")
        dur = praatio_scripts.audioio.WavQueryObj(wavFN).getDuration()
        tg = tgio.Textgrid()
        tier = tgio.IntervalTier("ipu", [(0, dur, txt), ], 0, dur)
github timmahrt / praatIO / examples / auto_segment_speech.py View on Github external
def autoSegmentSpeech(praatEXE, inputWavPath, rawTGPath, finalTGPath):
    
    utils.makeDir(finalTGPath)
    
    praat_scripts.annotateSilences(praatEXE, inputWavPath, rawTGPath)
    
    for tgFN in utils.findFiles(rawTGPath, filterExt=".TextGrid"):
        markTranscriptForAnnotations(join(rawTGPath, tgFN),
                                     "silences",
                                     join(finalTGPath, tgFN))
github timmahrt / praatIO / praatio / applied_scripts / sppas_util.py View on Github external
replaced by the textgrids SPPAS outputs
    '''
    
    if not os.path.exists(outputPath):
        os.mkdir(outputPath)
    
    if removeTierList is None:
        removeTierList = REMOVE_TIER_LIST
    
    if renameTierList is None:
        renameTierList = RENAME_TIER_LIST
    
    # Remove intermediate files
    if deleteIntermediateFiles is True:
        lowerTGList = utils.findFiles(tgPath, filterExt=".textgrid")
        xraList = utils.findFiles(tgPath, ".xra")
        removeList = lowerTGList + xraList
        for fn in removeList:
            os.remove(join(tgPath, fn))
    
    # Replace the textgrids input to SPPAS (suffixed with '-merge')
    # with the textgrids that SPPAS output
    tgFNList = utils.findFiles(tgPath, filterExt=".TextGrid")
    tgFNList = [fn for fn in tgFNList
                if '-merge' in fn]
    
    # Clean up the textgrids output by SPPAS
    # Rename tiers, delete tiers, and convert the phonetic tier
    # from xsampa to IPA
    for mergeFN in tgFNList:
        
        mergeName = os.path.splitext(mergeFN)[0]