How to use the praatio.dataio 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 / examples / get_vowel_points.py View on Github external
'''

import os
from os.path import join

from praatio import tgio
from praatio import dataio

path = join(".", "files")
outputPath = join(path, "point_process_output")

if not os.path.exists(outputPath):
    os.mkdir(outputPath)

tg = tgio.openTextgrid(join(path, "bobby_phones.TextGrid"))
pp = dataio.open1DPointObject(join(path, "bobby.PointProcess"))

newPoints = []
tier = tg.tierDict["phone"]
for start, stop, label in tier.entryList:
    if label.lower()[0] not in ["a", "e", "i", "o", "u"]:
        continue
    newPoints.extend([pp.getPointsInInterval(start, stop), ])

outputPP = dataio.PointObject1D(newPoints, dataio.POINT,
                                pp.minTime, pp.maxTime)
outputPP.save(join(outputPath, "bobby_vowels.PointProcess"))
github timmahrt / praatIO / praatio / praat_scripts.py View on Github external
def getPulses(praatEXE, inputWavFN, outputPointTierFN, minPitch, maxPitch,
              scriptFN=None):
    '''
    Gets the pitch/glottal pulses for an audio file.

    http://www.fon.hum.uva.nl/praat/manual/Sound___Pitch__To_PointProcess__peaks____.html
    '''
    if scriptFN is None:
        scriptFN = join(utils.scriptsPath, "get_pulses.praat")
    
    argList = [inputWavFN, outputPointTierFN, minPitch, maxPitch]
    utils.runPraatScript(praatEXE, scriptFN, argList)
    
    # Load the output
    pointObj = dataio.open1DPointObject(outputPointTierFN)
    
    return pointObj
github timmahrt / praatIO / praatio / pitch_and_intensity.py View on Github external
assert(os.path.exists(wavFN))
    firstTime = not os.path.exists(outputFN)
    if firstTime or forceRegenerate is True:
        if os.path.exists(outputFN):
            os.remove(outputFN)
        
        argList = [wavFN, outputFN, sampleStep,
                   minPitch, maxPitch, silenceThreshold,
                   medianFilterWindowSize, doInterpolation]
        
        scriptName = "get_pitchtier.praat"
        scriptFN = join(utils.scriptsPath, scriptName)
        utils.runPraatScript(praatEXE, scriptFN, argList)
    
    pitchTier = dataio.open2DPointObject(outputFN)
    
    return pitchTier
github timmahrt / praatIO / examples / get_vowel_points.py View on Github external
outputPath = join(path, "point_process_output")

if not os.path.exists(outputPath):
    os.mkdir(outputPath)

tg = tgio.openTextgrid(join(path, "bobby_phones.TextGrid"))
pp = dataio.open1DPointObject(join(path, "bobby.PointProcess"))

newPoints = []
tier = tg.tierDict["phone"]
for start, stop, label in tier.entryList:
    if label.lower()[0] not in ["a", "e", "i", "o", "u"]:
        continue
    newPoints.extend([pp.getPointsInInterval(start, stop), ])

outputPP = dataio.PointObject1D(newPoints, dataio.POINT,
                                pp.minTime, pp.maxTime)
outputPP.save(join(outputPath, "bobby_vowels.PointProcess"))
github timmahrt / ProMo / examples / pitch_morph_to_pitch_contour.py View on Github external
fromPitchFN = fromName + ".txt"
fromTGFN = join(root, fromName + ".TextGrid")

toName = "mary1_stylized"
toPitchFN = toName + ".PitchTier"

# Prepare the data for morphing
# 1st load it into memory
fromPitchList = pitch_and_intensity.extractPI(join(root, fromWavFN),
                                              join(root, fromPitchFN),
                                              praatEXE, minPitch,
                                              maxPitch, forceRegenerate=False)
fromPitchList = [(time, pitch) for time, pitch, _ in fromPitchList]

# Load in the target pitch contour
pitchTier = dataio.open2DPointObject(join(root, toPitchFN))
toPitchList = [(time, pitch) for time, pitch in pitchTier.pointList]

# The target contour doesn't contain enough sample points, so interpolate
# over the provided samples
# (this step can be skipped if there are enough sample points--a warning
# will be issued if there are any potential problems)
toPitchList = interpolation.quadraticInterpolation(toPitchList, 4, 1000, 0)

# 3rd select which sections to align.
# We'll use textgrids for this purpose.
tierName = "words"
fromPitch = f0_morph.getPitchForIntervals(fromPitchList, fromTGFN, tierName)
toPitch = f0_morph.getPitchForIntervals(toPitchList, fromTGFN, tierName)

# Run the morph process
f0_morph.f0Morph(fromWavFN=join(root, fromWavFN),