1

我在普拉特遇到了一些问题。特别是我需要编写一个脚本来提取,给定一个音频文件,音高,音高层,点处理和语音报告,然后将所有结果保存在不同的逗号分隔值文件中,就好像它们是我需要的 .csv稍后用 Python 打开。只要我将这些结果保存为 Praat 文本文件,我就没有问题,但是当涉及到表格时,我只能使用音高层和语音报告来创建它们。我尝试手动读取各种属性以构建表格,但其中一些属性无法访问,最大的问题是当我尝试访问导致脚本执行失败的帧时(这是我的代码米使用)

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

脚本失败了,这使我无法继续前进。同样,我不知道如何从点过程中获取表格。任何人都知道我的代码有什么问题,或者是否有更好的方法来获得相同(或至少相似)的结果?

4

0 回答 0