-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwritelns.praat
67 lines (52 loc) · 2.08 KB
/
writelns.praat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## writeln.praat: parse filename, write output file and PointProcess object
## James Kirby <j.kirby@ed.ac.uk>
## 23 February 2017
procedure writelns
## Parse filename into array
@splitstring: gridname$, separator$
## Turn this into a comma-separated list
lingVars$ = ""
for i from 1 to splitstring.strLen
lingVars$ = lingVars$ + splitstring.array$[i] + ","
endfor
## Note that because Praat Matrix objects can't contain characters,
## cols 2-5 of rows that have been 'discarded' are set to 0.
## This could potentially be handled more gracefully here, or can
## be dealt with at the analysis stage (e.g., by replacing 0s with
## NAs in your statistical analysis software).
## get interval label if we don't have it
if intervalNum <> 0
select TextGrid 'gridname$'
printIntervalLabel$ = Get label of interval... intervalTier intervalNum
else
printIntervalLabel$ = intervalLabel$
endif
## if you have at least one period:
if nb_periods > 0
for i from 1 to nb_periods-1
myFileLine$ = ""
## DEGG
select Matrix 'name$'_degg
currPeriod = Get value in cell... i 1
pstart = Get value in cell... i 2
pend = Get value in cell... i 3
f0 = Get value in cell... i 4
degg_oq = Get value in cell... i 5
myFileLine$ = myFileLine$ + name$ + "," + lingVars$ + printIntervalLabel$ + ",'currPeriod','pstart','pend','f0','degg_oq'"
## Howard
select Matrix 'name$'_howard
howard_oq = Get value in cell... i 5
myFileLine$ = myFileLine$ + ",'howard_oq'"
## If you want to add other measures, just continue to append them here
## Now, write to file
appendFileLine: "'directory$''outfile$'", "'myFileLine$'"
endfor
## if not:
else
myFileLine$ = name$ + "," + lingVars$ + printIntervalLabel$ + ",NA,NA,NA,NA,NA,NA"
appendFileLine: "'directory$''outfile$'", "'myFileLine$'"
endif
## Save PointProcess object
select PointProcess 'name$'_degg_both
Save as text file... 'directory$''name$'_degg_both.PointProcess
endproc