################################################################ # Praat script to get per-digit f0 info from read digit strings. # Command line: praat NumPitchScript basename # where audio is basename.wav # and segmentation is in tier 1 of basename.TextGrid # # Tier labels are expected to be single digits 0-9 # with string labels of the form #001 # # Per-string output will be string label # Per-digit output will be # time1 time2 meanf0 %ile20 %ile50 %ile80 maxf0 minf0 digit # e.g. # 2.287 2.487 122 119 120 122 130 118 3 # # Note that pitch range should be set appropriately # in the line "To Pitch... 0.0 75 170" # ################################################################ # ########################################## # Get base of filename # (from command line or interactively) ########################################## form Filename base word base foo endform outfile$ = "'base$'.pout" ############################ # Read in audio and TextGrid ############################ audio$ = "'base$'.wav" grid$ = "'base$'.TextGrid" Read from file... 'audio$' Read from file... 'grid$' ############# # track pitch ############# select Sound 'base$' sound = selected ("Sound") To Pitch... 0.0 75 170 pitch = selected ("Pitch") ################################# # Iterate over TextGrid intervals ################################# select TextGrid 'base$' textgrid = selected ("TextGrid") n = Get number of intervals... 1 printline # Data from 'base$' filedelete 'outfile$' fileappend 'outfile$' # Data from 'base$' 'newline$' for i to n select textgrid label$ = Get label of interval... 1 i if length(label$) > 1 printline 'label$' fileappend 'outfile$' 'label$' 'newline$' elsif length(label$) == 1 t1 = Get starting point... 1 i t2 = Get end point... 1 i select pitch mf0 = Get mean... t1 t2 Hertz f02 = Get quantile... t1 t2 0.2 Hertz f05 = Get quantile... t1 t2 0.5 Hertz f08 = Get quantile... t1 t2 0.8 Hertz xf0 = Get maximum... t1 t2 Hertz Parabolic if0 = Get minimum... t1 t2 Hertz Parabolic printline 't1:3' 't2:3' 'mf0:0' 'f02:0' 'f05:0' 'f08:0' 'xf0:0' 'if0:0' 'label$' fileappend 'outfile$' 't1:3' 't2:3' 'mf0:0' 'f02:0' 'f05:0' 'f08:0' 'xf0:0' 'if0:0' 'label$' 'newline$' endif endfor