12/27/2023 0 Comments Script praat textgrid to csvscriptsPath, "annotate_silences.praat" ) utils. runPraatScript ( praatEXE, scriptFN, , ) def annotateSilences ( praatEXE : str, inputWavPath : str, outputTGPath : str, minPitch : float = 100, timeStep : float = 0.0, silenceThreshold : float = - 25.0, minSilDur : float = 0.1, minSoundDur : float = 0.1, silentLabel : str = SILENCE_LABEL, soundLabel : str = SOUND_LABEL, scriptFN : Optional = None, ) -> None : """Marks the silences and non-silences of an audio file Uses the praat command: """ if scriptFN is None : scriptFN = join ( utils. scriptsPath, "resynthesize_duration.praat" ) utils. runPraatScript ( praatEXE, scriptFN, ) def resynthesizeDuration ( praatEXE : str, inputWavFN : str, durationTierFN : str, outputWavFN : str, minPitch : float, maxPitch : float, scriptFN : Optional = None, ) -> None : """Resynthesizes the duration in a wav file with the given duration tier Uses the following praat command: """ if scriptFN is None : scriptFN = join ( utils. scriptsPath, "resynthesize_pitch.praat" ) if pointList is not None : dur = audio. Uses the following praat command: """ if scriptFN is None : scriptFN = join ( utils. If so, it will be saved as pitchFN for praat to be able to use. split ( " \n " ) dataListOfLists = titleRow, mainDataListOfLists = dataListOfLists, dataListOfLists return titleRow, mainDataListOfLists def resynthesizePitch ( praatEXE : str, inputWavFN : str, pitchFN : str, outputWavFN : str, minPitch : float, maxPitch : float, scriptFN : Optional = None, pointList : Optional = None, ) -> None : """Resynthesizes the pitch in a wav file with the given pitch contour file The pitch track to use can optionally be passed in as pointList. open ( outputCSVFN, "r", encoding = "utf-8" ) as fd : data = fd. runPraatScript ( praatEXE, scriptFN, argList ) # Load the output with io. scriptsPath, "get_spectral_info.praat" ) argList = utils. open1DPointObject ( outputPointTierFN ) return pointObj def getSpectralInfo ( praatEXE : str, inputWavFN : str, inputTGFN : str, outputCSVFN : str, tierName : str, spectralPower : int = 2, spectralMoment : int = 3, scriptFN : Optional = None, ) -> Tuple : """Extracts various spectral measures from an audio file Measures include: center_of_gravity, standard_deviation skewness, kertosis, central_movement Uses the following praat command: """ if scriptFN is None : scriptFN = join ( utils. runPraatScript ( praatEXE, scriptFN, argList ) # Load the output pointObj = data_points. scriptsPath, "get_pulses.praat" ) argList = utils. PointObject1D : """Gets the pitch/glottal pulses for an audio file. runPraatScript ( praatEXE, scriptFN, ) def getFormants ( praatEXE : str, inputWavFN : str, outputTxtFN : str, maxFormant : float, stepSize : float = 0.01, window_length : float = 0.025, preemphasis : float = 50, scriptFN : Optional = None, undefinedValue : Optional = None, ) -> List : """Get F1, F2, and F3 for the audio file maxFormant = 5500 for females, 5000 for males, data_points. scriptsPath, "change_intensity.praat" ) # Praat crashes on exit after resynthesis with a klattgrid utils. runPraatScript ( praatEXE, scriptFN, , ) def changeIntensity ( praatEXE : str, wavFN : str, outputWavFN : str, newIntensity : float, scriptFN : Optional = None, ) -> None : """Changes the intensity of the wavFN (in db) Uses the following praat command: """ if scriptFN is None : scriptFN = join ( utils. scriptsPath, "change_gender.praat" ) # Praat crashes on exit after resynthesis with a klattgrid utils. see **examples/auto_segment_speech.py**, **examples/get_pitch_and_formants.py**, **klatt_resynthesis.py** """ import os from os.path import join import io import csv from typing import List, Optional, Tuple from praatio import audio from praatio import data_points from praatio.utilities import constants from praatio.utilities import utils SILENCE_LABEL = "silent" SOUND_LABEL = "sound" def changeGender ( praatEXE : str, wavFN : str, outputWavFN : str, pitchFloor : float, pitchCeiling : float, formantShiftRatio : float, pitchMedian : float = 0.0, pitchRange : float = 1.0, duration : float = 1.0, scriptFN : Optional = None, ) -> None : """Changes the speech formants in a file using praat's change gender function PitchMedian = 0.0 no change in median pitch PitchRange = 1.0 no change in pitch range Uses the following praat command: """ if scriptFN is None : scriptFN = join ( utils. """ Python wrappers for various praat scripts contained in /praatScripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |