Date
1  2 of 2
Centroid
Kyuchul Yoon <kyoon@...>
Hello,
I'm working on Korean fricatives and I need to get centroids from a series of spectrum objects. Could anyone tell me how to do this in Praat? Is it also possible to get centroids from a spectrogram object so I won't have to extract spectra every 5 or 10 msec? Thank you very much ***** Kyuchul Yoon kyoon@... Department of Linguistics The Ohio State University http://ling.ohiostate.edu/~kyoon/ *****


Paul Boersma <paul.boersma@...>
Kyuchul Yoon wrote:
I'm working on Korean fricatives and I need to get centroids from a series of spectrum objects.to compute the spectral centroid, select a Spectrum object and run the following script. The script could be much shorter, but the following script makes explicit the steps in the computation of the centroid, which is defined as integral S^2(f) f df / integral S^2(f) df where S^2(f) = Re(S)^2 + Im(S)^2, where S is the complex spectrum. Copy... power # Convert from complex to power: Formula... if row=1 then self[1,col]^2+self[2,col]^2 else 0 fi # Weight by frequency: Copy... weighted Formula... self * x # Integrate: select Spectrum power plus Spectrum weighted Formula... self + self [col1] # Get last element: select Spectrum power lastBin = Get number of bins power = Get real value in bin... lastBin select Spectrum weighted weightedPower = Get real value in bin... lastBin centroid = weightedPower / power select Spectrum power plus Spectrum weighted Remove echo 'centroid' Is it also possible to get centroids from a spectrogram object soSelect a Spectrogram object, then use "To Spectrum (slice)" in a loop (in a script) and run the above script on it. Instead of echo 'centroid' you may want to say printline 'centroid' to get all values in the Info window.  Paul Boersma Institute of Phonetic Sciences, University of Amsterdam Herengracht 338, 1016CG Amsterdam, The Netherlands http://www.fon.hum.uva.nl/paul/ phone +31205252385

