# jm, 2014-05-02 # measures some spectral characteristics of vowels # measurements: # - mean and standard deviation of F1 and F2 # - pitch median # - H1-H2 (voice quality) # - H1-A1, H1-A2, H1-A3 (spectral tilt) # Usage: # This is an editor script!! # - open Sound object in an editor # - load script to the editor # - select stable part of a vowel # - run script form Settings choice Speaker_is 2 button male button female endform if speaker_is = 1 maxFormant = 5000 else maxFormant = 5500 endif # extract selection len = Get selection length if len < 0.061 writeInfoLine: "Selection too short!" appendInfoLine: "You selected ", len, " s." appendInfoLine: "Minimum is 0.061 s." exitScript () endif len$ = fixed$ (len, 3) i$ = Sound info n$ = extractWord$ (i$, "Object name:") Move start of selection to nearest zero crossing Move end of selection to nearest zero crossing s = Extract selected sound (windowed): "vowel", "Hanning", 1, "no" endeditor # measure formants f = noprogress To Formant (burg): 0, 5, maxFormant, 0.025, 50 m1 = Get mean: 1, 0, 0, "Hertz" m1$ = fixed$ (m1, 1) m2 = Get mean: 2, 0, 0, "Hertz" m2$ = fixed$ (m2, 1) sd1 = Get standard deviation: 1, 0, 0, "Hertz" sd1$ = fixed$ (sd1, 2) sd2 = Get standard deviation: 2, 0, 0, "Hertz" sd2$ = fixed$ (sd2, 2) # estimate pitch range (Hirst, 2011) selectObject: s p = noprogress To Pitch: 0.01, 50, 700 q1 = Get quantile: 0, 0, 0.25, "Hertz" q3 = Get quantile: 0, 0, 0.75, "Hertz" floor = round (q1*0.75) ceiling = round (q3*2.5) removeObject: p selectObject: s p1 = noprogress To Pitch: 0.01, floor, ceiling medp = Get quantile: 0, 0, 0.5, "Hertz" # voice quality (H1-H2) selectObject: s p2 = noprogress To Pitch (cc): 0, floor, 15, "yes", 0.03, 0.55, 0.01, 0.35, 0.14, ceiling selectObject: s,p2 pp = noprogress To PointProcess (cc) n = Get number of points if n > 0 selectObject: s,pp l1 = noprogress To Ltas (only harmonics): 20, 0.0001, 0.02, 1.3 h1 = Get value in bin: 2 h2 = Get value in bin: 3 h1h2 = h1 - h2 h1h2$ = fixed$ (h1h2, 3) + " dB" else h1h2$ = "undefined" endif # H1-[A1,A2,A3] selectObject: f med1 = Get quantile: 1, 0.0, 0.0, "Hertz", 0.5 med2 = Get quantile: 2, 0.0, 0.0, "Hertz", 0.5 med3 = Get quantile: 3, 0.0, 0.0, "Hertz", 0.5 selectObject: s l2 = noprogress To Ltas: 100 h1 = Get value at frequency: medp, "Nearest" a1 = Get value at frequency: med1, "Nearest" a2 = Get value at frequency: med2, "Nearest" a3 = Get value at frequency: med3, "Nearest" h1a1$ = fixed$ (h1-a1,3) + " dB" h1a2$ = fixed$ (h1-a2,3) + " dB" h1a3$ = fixed$ (h1-a3,3) + " dB" # generate output writeInfoLine: n$, " (", speaker_is$, " speaker)" appendInfoLine: len$, " s selected" appendInfoLine: "F1", tab$, "Mean = ", m1$, " Hz", tab$, tab$, "SD = ", sd1$, " Hz" appendInfoLine: "F2", tab$, "Mean = ", m2$, " Hz", tab$, tab$, "SD = ", sd2$, " Hz" appendInfoLine: "H1-H2 = ", h1h2$ appendInfoLine: "H1-A1 = ", h1a1$ appendInfoLine: "H1-A2 = ", h1a2$ appendInfoLine: "H1-A3 = ", h1a3$ # clean up nocheck removeObject (s,f,p1,p2,pp,l1,l2)