diff --git a/fave/extractFormants.py b/fave/extractFormants.py index 4aac0ec..e6b80a6 100755 --- a/fave/extractFormants.py +++ b/fave/extractFormants.py @@ -92,7 +92,6 @@ from fave.extract.remeasure import remeasure from fave.extract.mahalanobis import mahalanobis -SCRIPTS_HOME = pkg_resources.resource_filename('fave','praatScripts') os.chdir(os.getcwd()) uncertain = re.compile(r"\(\(([\*\+]?['\w]+\-?)\)\)") @@ -448,29 +447,6 @@ def checkLocation(file): sys.exit() -def checkSpeechSoftware(speechSoftware): - """checks that either Praat or ESPS is available as a speech analysis program""" - - if speechSoftware in ['ESPS', 'esps']: - if os.name == 'nt': - print("ERROR: ESPS was specified as the speech analysis program, but this option is not yet compatible with Windows") - sys.exit() - if not programExists('formant'): - print("ERROR: ESPS was specified as the speech analysis program, but the command 'formant' is not in your path") - sys.exit() - else: - return 'esps' - elif speechSoftware in ['praat', 'Praat']: - if not ((PRAATPATH and programExists(speechSoftware, PRAATPATH)) or (os.name == 'posix' and programExists(speechSoftware)) or (os.name == 'nt' and programExists('praatcon.exe'))): - print("ERROR: Praat was specified as the speech analysis program, but the command 'praat' ('praatcon' for Windows) is not in your path") - sys.exit() - else: - return speechSoftware - else: - print("ERROR: unsupported speech analysis software %s" % speechSoftware) - sys.exit() - - def checkTextGridFile(tgFile): """checks whether a TextGrid file exists and has the correct file format""" @@ -828,7 +804,7 @@ def getTransitionLength(minimum, maximum): return transition -def getVowelMeasurement(sound_part, p, w, speechSoftware, formantPredictionMethod, measurementPointMethod, nFormants, maxFormant, windowSize, preEmphasis, padBeg, padEnd, speaker): +def getVowelMeasurement(sound_part, p, w, formantPredictionMethod, measurementPointMethod, nFormants, maxFormant, windowSize, preEmphasis, padBeg, padEnd, speaker): """makes a vowel measurement""" if formantPredictionMethod == 'mahalanobis': @@ -1667,26 +1643,6 @@ def processInput(wavInput, tgInput, output): outputFiles = open(output, 'r').read().splitlines() return (wavFiles, tgFiles, outputFiles) - -def programExists(program, path=''): - """checks whether a given command line program exists (path can be specified optionally)""" - - if not path: - if os.name == 'posix': - pathDirs = os.environ['PATH'].split(':') - elif os.name == 'nt': - pathDirs = os.environ['PATH'].split(';') - else: - print("ERROR: did not recognize OS type '%s'. Paths to 'praat' and 'sox' must be specified manually" % os.name) - sys.exit() - for p in pathDirs: - if os.path.isfile(os.path.join(p, program)): - return True - return False - else: # path is specified - return os.path.isfile(os.path.join(path, program)) - - def readSpeakerFile(speakerFile): """reads speaker background information from a speaker file""" @@ -1790,8 +1746,6 @@ def setup_parser(): help="Do a second pass is performed on the data, using the speaker's own system as the base of comparison for the Mahalanobis distance") parser.add_argument("--removeStopWords", action="store_true", help="Don't measure vowels in stop words." ) - parser.add_argument("--speechSoftware", choices = ['praat', 'Praat', 'esps', 'ESPS'], default = "Praat", - help="The speech software program to be used for LPC analysis.") parser.add_argument("--speaker", "-s", help = "*.speaker file, if used") parser.add_argument("--stopWords", nargs="+", default=["AND", "BUT", "FOR", "HE", "HE'S", "HUH", "I", "I'LL", "I'M", "IS", "IT", "IT'S", "ITS", "MY", "OF", "OH", @@ -1959,7 +1913,6 @@ def writeLog(filename, wavFile, maxTime, meansFile, covsFile, opts): f.write("- nSmoothing:\t\t\t%i\n" % opts.nSmoothing) f.write("- windowSize:\t\t\t%.3f\n" % opts.windowSize) f.write("- preEmphasis:\t\t\t%i\n" % opts.preEmphasis) - f.write("- speechSoftware:\t\t%s\n" % opts.speechSoftware) f.write("- outputFormat:\t\t\t%s\n" % opts.outputFormat) f.write("- outputHeader:\t\t\t%s\n" % (not opts.noOutputHeader)) f.write("- case:\t\t\t\t%s\n" % opts.case) @@ -2059,7 +2012,6 @@ def extractFormants(wavInput, tgInput, output, opts, SPATH='', PPATH=''): formantPredictionMethod = opts.formantPredictionMethod measurementPointMethod = opts.measurementPointMethod mfa = opts.mfa - speechSoftware = opts.speechSoftware nFormants = opts.nFormants #maxFormant = opts.maxFormant nSmoothing = opts.nSmoothing @@ -2079,14 +2031,6 @@ def extractFormants(wavInput, tgInput, output, opts, SPATH='', PPATH=''): phoneset = cmu.read_phoneset(opts.phoneset) print("Read CMU phone set.") - # # make sure the specified speech analysis program is in our path - # speechSoftware = checkSpeechSoftware(opts.speechSoftware) - # print("Speech software to be used is %s." % speechSoftware) - - # # determine what program we'll use to extract portions of the audio file - # soundEditor = getSoundEditor() - # print("Sound editor to be used is %s." % soundEditor) - # if we're using the Mahalanobis distance metric for vowel formant prediction, # we need to load files with the mean and covariance values if formantPredictionMethod == 'mahalanobis': @@ -2281,7 +2225,7 @@ def extractFormants(wavInput, tgInput, output, opts, SPATH='', PPATH=''): sound_part = sound.extract_part(from_time = p.xmin - padBeg, to_time = p.xmax + padEnd) - vm = getVowelMeasurement(sound_part, p, w, opts.speechSoftware, + vm = getVowelMeasurement(sound_part, p, w, formantPredictionMethod, measurementPointMethod, nFormants, maxFormant, windowSize, preEmphasis, padBeg, padEnd, speaker) if vm: # if vowel is too short for smoothing, nothing will be returned diff --git a/fave/praatScripts/extractFormants.praat b/fave/praatScripts/extractFormants.praat deleted file mode 100755 index fd5678c..0000000 --- a/fave/praatScripts/extractFormants.praat +++ /dev/null @@ -1,29 +0,0 @@ -# Usage: praat extractFormants.praat filename.wav nFormants maxFormant windowSize preEmphasis method - -form Get_arguments - word audioFile - integer nFormants - integer maxFormant - real windowSize - integer preEmphasis - word method -endform - -# get the number of characters in the file name -flen = length(audioFile$) -# cut off the final '.wav' (or other three-character file extension) to get the full path of the .Formant file that we will create -path$ = left$ (audioFile$, flen-4) - -Read from file... 'audioFile$' - -if method$ == "all" - To Formant (keep all)... 0.001 'nFormants' 'maxFormant' 'windowSize' 'preEmphasis' -# To Formant (keep all)... 0.0 'nFormants' 'maxFormant' 'windowSize' 'preEmphasis' -# by default, use the Burg method -else - To Formant (burg)... 0.001 'nFormants' 'maxFormant' 'windowSize' 'preEmphasis' -# To Formant (burg)... 0.0 'nFormants' 'maxFormant' 'windowSize' 'preEmphasis' -endif - -#echo writing Praat Formant file: 'path$'.Formant -Write to short text file... 'path$'.Formant \ No newline at end of file diff --git a/fave/praatScripts/extractSegment.praat b/fave/praatScripts/extractSegment.praat deleted file mode 100755 index ced02a6..0000000 --- a/fave/praatScripts/extractSegment.praat +++ /dev/null @@ -1,12 +0,0 @@ -form Get_arguments - text infile - text outfile - real beg - real end -endform - -Read from file... 'infile$' -wavname$ = selected$ ("Sound") -Extract part... 'beg' 'end' Rectangular 1 no -Write to WAV file... 'outfile$' -echo extracted audio segment from 'beg' sec to 'end' sec as 'outfile$' diff --git a/fave/praatScripts/getIntensity.praat b/fave/praatScripts/getIntensity.praat deleted file mode 100644 index 4f2f0f3..0000000 --- a/fave/praatScripts/getIntensity.praat +++ /dev/null @@ -1,23 +0,0 @@ -## Praat script for getting the intensity contour for a given sound file -## written by Ingrid Rosenfelder -## last modified April 17, 2013 - -## Usage: praat getIntensity.praat filename.wav - -form Please specify the sound file: - sentence audioFile -endform - -filename$ = audioFile$ - ".wav" + ".Intensity" - -Read from file... 'audioFile$' -duration = Get total duration -## minimum duration to get an intensity contour is 6.4 divided by the cutoff frequency -## so we need to check that our vowel meets this criterion -if duration >= 0.064 - To Intensity... 100 0.001 yes -else - analysis_frequency = 6.4 / duration - To Intensity... 'analysis_frequency' 0.001 yes -endif -Write to short text file... 'filename$' \ No newline at end of file diff --git a/fave/praatScripts/get_duration.praat b/fave/praatScripts/get_duration.praat deleted file mode 100644 index 1530d65..0000000 --- a/fave/praatScripts/get_duration.praat +++ /dev/null @@ -1,16 +0,0 @@ -## Praat script to get the duration of a sound file -## because Python's wave.py module does not seem to support 32-bit .wav sound files -## written by Ingrid Rosenfelder -## last modified November 18, 2011 - -## usage: praat get_duration.praat soundfile - -################################################################# -form Get Sound file - sentence Sound_file_path /Users/ingrid/Programs/Forced_Alignment_Toolkit/17Nov2011_14:30:05_Barb1.wav -endform - -Open long sound file... 'sound_file_path$' -duration = Get total duration -clearinfo -print 'duration' \ No newline at end of file