Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for longer files.
Returns the result as a list. Will load the serialized result
if this has already been called on the appropriate files before
'''
outputPath = os.path.split(outputFN)[0]
utils.makeDir(outputPath)
windowSize = medianFilterWindowSize
assert(os.path.exists(inputFN))
firstTime = not os.path.exists(outputFN)
if firstTime or forceRegenerate is True:
utils.makeDir(tmpOutputPath)
splitAudioList = praatio_scripts.splitAudioOnTier(inputFN,
tgFN,
tierName,
tmpOutputPath,
False)
allPIList = []
for start, _, fn in splitAudioList:
tmpTrackName = os.path.splitext(fn)[0] + ".txt"
piList = _extractPIFile(join(tmpOutputPath, fn),
join(tmpOutputPath, tmpTrackName),
praatEXE, minPitch, maxPitch,
sampleStep, silenceThreshold,
pitchUnit, forceRegenerate=True,
medianFilterWindowSize=windowSize,
pitchQuadInterp=pitchQuadInterp)
piList = [("%0.3f" % (float(time) + start), str(pV), str(iV))
for time, pV, iV in piList]
def _runSpeechRateEstimateOnIntervals(wavPath, tgPath, tierName, wavTmpPath,
syllableNucleiPath, matlabEXE,
matlabScriptsPath, printCmd=True,
outputTGFlag=False):
utils.makeDir(wavTmpPath)
# Split audio files into subsections based on textgrid intervals
for name in utils.findFiles(wavPath, filterExt=".wav", stripExt=True):
praatio_scripts.splitAudioOnTier(join(wavPath, name + ".wav"),
join(tgPath, name + ".TextGrid"),
tierName, wavTmpPath, outputTGFlag)
uwe_sr.findSyllableNuclei(wavTmpPath, syllableNucleiPath, matlabEXE,
matlabScriptsPath, printCmd)
'''
import os
from os.path import join
from praatio import praatio_scripts
path = join(".", "files")
outputPath = join(path, "sub_wavs")
if not os.path.exists(outputPath):
os.mkdir(outputPath)
for wavFN, tgFN in [#("bobby.wav", "bobby_words.TextGrid"),
("mary.wav", "mary.TextGrid")]:
praatio_scripts.splitAudioOnTier(join(path, wavFN),
join(path, tgFN),
"phone",
outputPath,
True)