How does Praat calculate the mean of a Pitch object?
Austin Zheng
When I turn off the path finder, use the To Pitch (ac) function, and use the Get Mean function on the resulting Pitch object, I get a significantly different mean value from the mean of the locally strongest candidates in each frame (computed with another program). Could I ask how the Get Mean function works for a Pitch object?


Boersma Paul
On 6 Dec 2019, at 03:47, Austin Zheng <azaustinzheng@...> wrote:
Your question is very vague. Can you explain exactly what you did, i.e. all the steps in Praat, plus how you moved the pitch data to that other program, and all the steps in that other program? _____ Paul Boersma Professor of Phonetic Sciences, University of Amsterdam Visiting address: Spuistraat 134, room 632, Amsterdam Mail: P.O. Box 1642, 1000BP Amsterdam, The Netherlands Website: http://www.fon.hum.uva.nl/paul/


Austin Zheng
Thank you for your reply. I undertook the following steps:
1. Load the clip into Praat 2. Use the To Pitch (ac) program in Praat with the following parameters: TimeStep: 60 ms; PitchFloor: 50 Hz; PitchCeiling: 400 Hz; SilenceThreshold: 0; VoicingThreshold: 0; OctaveCost: 0.01; OctaveJumpCost: 0; VoicedUnvoicedCost: 0; Hanning window 3. Use the Get Mean function in Praat with From Time of 0 and To Time of 0 To move and process the pitch data in Python, I did the following: 4. Save the Pitch object in a .txt file using Praat 5. Convert the .txt file to a .csv file using Python 6. Use Python to read the .csv file, filter out all candidates with frequency above 400 Hz, and select the candidate with the highest strength for each frame. Call these the strongest candidates. 7. Use Python's statistics.mean() function (documentation here: https://docs.python.org/3.7/library/statistics.html#statistics.mean) to calculate the mean of the frequencies of the strongest candidates. The mean value I get from Python differs from that in Praat by ~20 Hz. I further verify this by using Python to output the frequencies of the strongest candidates in a .csv file, and using Excel to calculate the means of these frequencies. Excel produces the same mean value as Python, and a different one from Praat.


Boersma Paul
On 6 Dec 2019, at 16:24, Austin Zheng <azaustinzheng@...> wrote:
Thanks for the clarity. The difference is due to the OctaveCost: you can see that if you set this to a different value, the result in Praat will change but in Python it will not. In fact, the values you get in Python are those that you get in Praat by setting OctaveCost to 0. This does not mean that OctaveCost should be 0. If you need the best local pitch values, set OctaveCost to 0.01 in Praat, and in Python add to each strength the following number before selecting the winner: 0.01 * log2 (frequency) (I assume you have already removed the ones with frequency 0, which are the locally unvoiced frames) If instead you need the rawest pitch values in Python, e.g. to train an artificial neural network, then ignore the octave cost and have the network figure it all out. You should then keep all the candidates, not just one. This is how my student Jona Bosman did it earlier this year (www.fon.hum.uva.nl/archive/2019/2019BAJonaBosman.pdf). _____ Paul Boersma Professor of Phonetic Sciences, University of Amsterdam Visiting address: Spuistraat 134, room 632, Amsterdam Mail: P.O. Box 1642, 1000BP Amsterdam, The Netherlands Website: http://www.fon.hum.uva.nl/paul/

