def generate_variable_formants_point_function(corpus_context, min_formants, max_formants): """Generates a function used to call Praat to measure formants and bandwidths with variable num_formants. Parameters ---------- corpus_context : :class:`~polyglot.corpus.context.CorpusContext` The CorpusContext object of the corpus. min_formants : int The minimum number of formants to measure with on subsequent passes (default is 4). max_formants : int The maximum number of formants to measure with on subsequent passes (default is 7). Returns ------- formant_function : Partial function object The function used to call Praat. """ max_freq = 5500 script_dir = os.path.dirname(os.path.abspath(__file__)) script = os.path.join(script_dir, 'multiple_num_formants.praat') formant_function = PraatAnalysisFunction( script, praat_path=corpus_context.config.praat_path, arguments=[0.01, 0.025, min_formants, max_formants, max_freq]) formant_function._function._output_parse_function = parse_multiple_formant_output return formant_function
def generate_praat_script_function(praat_path, script_path, arguments=None): """ Generate a partial function that calls the praat script specified. (used as input to analyze_file_segments) Parameters ---------- praat_path : string full path to praat/praatcon script_path: string full path to the script arguments : list a list containing any arguments to the praat script, optional (currently not implemented) Returns ---------- function the partial function which applies the Praat script to a phone and returns the script output """ praat_function = PraatAnalysisFunction(script_path, praat_path=praat_path, arguments=arguments) return praat_function