简单的方法
最简单的方法是将输出写入Table
对象,然后使用 Praat 的Save to comma-separated file
命令将其保存到外部文件。下面的示例使用新的(稍微更合理的)新语法,因此请确保在尝试之前更新 Praat(或尝试此答案的编辑历史记录中的速记版本)。
这是一个例子:
# Create a Table with no rows
table = Create Table with column names:
..."table", 0, "Narrative Label Midpoint Time F1 F2 F3"
for i to number_of_intervals
# Assuming you have your Formant objects in an array named "burg"
selectObject(burg[i])
# Run your analysis here
# For this example, I'm assuming values for the columns are in
# variables called narrative$, label$, midpoint, time, f1, f2 and f3
selectObject(table)
Append row
current_row = Get number of rows
# Insert your values
Set string value: current_row, "Narrative", narrative$
Set string value: current_row, "Label", label$
Set numeric value: current_row, "Midpoint", midpoint
Set numeric value: current_row, "Time", time
Set numeric value: current_row, "F1", f1
Set numeric value: current_row, "F2", f2
Set numeric value: current_row, "F3", f3
endfor
# Save it!
# Remember to select it if the table is not the active selection at
# the end of the loop
Save to comma-separated file: /path/to/file
# And then you can get rid of it
removeObject(table)
或者你可以使用,如果你喜欢标签
Save to tab-separated file: /path/to/file
请注意,此方法不允许您使用“Narrative#”作为列名。
'l33t' 方式
或者,您可以使用 Praat 的文件指令按照文档中的说明直接写入文件:
sep$ = ","
# sep$ = tab$
# Create / overwrite file and write header
writeFileLine: "/path/to/file",
..."Narrative#" + sep$ +
..."Label" + sep$ +
..."Midpoint" + sep$ +
..."Time" + sep$ +
..."F1" + sep$ +
..."F2" + sep$ +
..."F3"
for i to number_of_intervals
selectObject(burg[i])
# Run your analysis here
appendFileLine: "/path/to/file",
...narrative$ + sep$ +
...label$ + sep$ +
...string$(midpoint) + sep$ +
...string$(time) + sep$ +
...string$(f1) + sep$ +
...string$(f2) + sep$ +
...string$(f3)
endfor