Debian Codegraph @

docs/manual/Script_for_listing_F0_statistics.html

raw symbols SCIP
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Script for listing F0 statistics</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 Script for listing F0 statistics
13 </b></font></table></table>
14 <p>"I need to split the wave into 50 msec sections, and then for each of those sections get the F0 statistics. That is, for each 50 msec section of speech I want to get the average F0, min, max, and standard deviation."</p>
15 <p>First you create the complete pitch contour, i.e., you select the Sound and choose <a href="Sound__To_Pitch___.html">To Pitch...</a>. You can then use the commands from the <a href="Query_submenu.html">Query submenu</a> in a loop:</p>
16 <code> startTime = Get start time<br></code>
17 <code> endTime = Get end time<br></code>
18 <code> numberOfTimeSteps = (endTime - startTime) / 0.05<br></code>
19 <code> writeInfoLine: " tmin tmax mean fmin fmax stdev"<br></code>
20 <code> for step to numberOfTimeSteps<br></code>
21 <code> tmin = startTime + (step - 1) * 0.05<br></code>
22 <code> tmax = tmin + 0.05<br></code>
23 <code> mean = Get mean: tmin, tmax, "Hertz"<br></code>
24 <code> minimum = Get minimum: tmin, tmax, "Hertz", "Parabolic"<br></code>
25 <code> maximum = Get maximum: tmin, tmax, "Hertz", "Parabolic"<br></code>
26 <code> stdev = Get standard deviation: tmin, tmax, "Hertz"<br></code>
27 <code> appendInfoLine: fixed$ (tmin, 6), " ", fixed$ (tmax, 6), " ", fixed$ (mean, 2),<br></code>
28 <code> ... " ", fixed$ (minimum, 2), " ", fixed$ (maximum, 2), " ", fixed$ (stdev, 2)<br></code>
29 <code> endfor<br></code>
30 <h2>Notes</h2>
31 <p>One should not cut the sound up into pieces of 50 ms and then do <b>To Pitch...</b> on each of them, because Praat will not compute F0 values in the first or last 20 ms (or so) of each piece. This is because the analysis requires a window of 40 ms (or so) for every pitch frame. Instead, one typically does the analysis on the whole sound, then queries the resulting large Pitch object. In that way, the information loss of windowing only affects the two 20 ms edges of the whole sound.</p>
32 <p>The example writes lines to the <b>Info</b> window. If you want to write to a file instead, you start with something like</p>
33 <code> deleteFile: "~/results/out.txt"<br></code>
34 <p>and add lines in the following way:</p>
35 <code> appendFileLine: "~/results/out.txt ", fixed$ (tmin, 6), " ", fixed$ (tmax, 6), " ",<br></code>
36 <code> ... fixed$ (mean, 2), " ", fixed$ (minimum, 2), " ", fixed$ (maximum, 2), " ",<br></code>
37 <code> ... fixed$ (stdev, 2)<br></code>
38 <h3>Links to this page</h3>
39 <ul>
40 <li><a href="Scripting_examples.html">Scripting examples</a>
41 </ul>
42 <hr>
43 <address>
44 <p>© ppgb 20221202</p>
45 </address>
46 </body>
47 </html>