我对Praat遇到了一些问题。特别是我需要编写一个脚本,该脚本提取给定的音频文件,音高,音高等级,指向过程和语音报告,然后将所有结果保存在不同的逗号分隔值文件中,就像它们是我需要的.csv一样。稍后使用Python打开。 只要将这些结果保存为Praat文本文件,我就没有问题,但是对于表格,我只能使用音调层和语音报告来创建它们。使用Pitch时,我尝试手动读取各种属性以构建表格,但是其中一些不可用,最大的问题是当我尝试访问导致脚本执行失败的帧时(这是我的代码) m正在使用)
audio = Read from file:name$
pitch = To Pitch: 0.0, 75, 300
pitch_table_columns$ = "xmin xmax nx dx x1 ceiling max_n_candidates frame_n frame_intensity frame_n_candidates frame_candidate_n frame_candidate_frequency frame_candidate_strength"
pitch_table = Create Table with column names: "pitch_table", 0, pitch_table_columns$
selectObject: pitch
xmin = Object_'pitch'.xmin
xmax = Object_'pitch'.xmax
nx = Object_'pitch'.nx
dx = Object_'pitch'.dx
#x1 = Object_'pitch'.x1
#ceiling = 300
#maxncandidates = Object_'pitch'.maxnCandidates
frames = Get number of frames
selectObject: pitch
for i from 1 to frames
#intensity = Object_'pitch'.frame[i].intensity
ncandidates = Object_'pitch'.frame[i].nCandidates
for j in ncandidates
frequency = Object_'pitch'.frame[i].candidate[j].frequency
strength = Object_'pitch'.frame[i].candidate[j].strength
selectObject: pitch_table
Append row
r = Get number of rows
Set numeric value: r, "xmin", xmin
Set numeric value: r, "xmax", xmax
Set numeric value: r, "nx", nx
Set numeric value: r, "dx", dx
Set numeric value: r, "x1", x1
Set numeric value: r, "ceiling", ceiling
Set numeric value: r, "max_n_candidates", maxncandidates
Set numeric value: r, "frame_n", i
Set numeric value: r, "frame_intensity", intensity
Set numeric value: r, "frame_n_candidates", ncandidates
Set numeric value: r, "frame_candidate_n", j
Set numeric value: r, "frame_candidate_frequency", frequency
Set numeric value: r, "frame_candidate_strength", strength
endfor
endfor
selectObject: pitch
Save as text file: "pitch.Pitch"
selectObject: pitch_table
Save as comma-separated file: "table.csv"
注释掉的行是针对我无法访问的属性的,但是当我进入时
ncandidates = Object_'pitch'.frame[i].nCandidates
脚本失败,这使我无法继续前进。 同样,我也不知道如何从指向过程中获取表。 有谁知道我的代码有什么问题,或者是否有更好的方法来获得相同(或至少相似)的结果?