0
我正在修改脚本,对于每个音频文件和文本文件夹中的文本,我会遍历每个音节标签,将标签分成三个相等部分,然后提取每个部分中点的音调并将有关中点和相应音高的信息保存到文本文件中,我将其保存在同一个目录中。当我运行脚本时,生成的文本文件只包含标题。您是否能够识别阻止我访问和/或保存我试图提取的信息的错误?下面我粘贴了一些代码,我正在计算中点并提取这些点的音高。在计算的点或边界处的Praat音高提取(不是平均音高间隔)
# Write a row with column titles to the result file:
titleline$ = "Filename Syllable Midpoint1 Midpoint2 Midpoint3 Pitch1 Pitch2 Pitch3'newline$'"
fileappend "'resultfile$'" 'titleline$'
# Go through all the sound files, one by one:
for i from 1 to numberOfFiles
filename$ = Get string... ifile
# A sound file is opened from the listing:
Read from file: 'sound_directory$''filename$'
# Starting from here, you can add everything that should be
# repeated for every sound file that was opened:
soundname$ = selected$ ("Sound", 1)
To Pitch... Time_step Minimum_pitch Maximum_pitch
# Open a TextGrid by the same name:
gridfile$ = "'textGrid_directory$''soundname$''textGrid_file_extension$'"
if fileReadable (gridfile$)
Read from file... 'gridfile$'
# Find the tier number that has the label given in the form:
call GetTier 'tier$' tier
numberOfIntervals = Get number of intervals... tier
# Pass through all intervals in the selected tier:
for interval to numberOfIntervals
label$ = Get label of interval... tier interval
if label$ <> ""
# if the interval has an unempty label, get its start and end:
start = Get starting point... tier interval
end = Get end point... tier interval
dur = end - start
# divide interval into 3 segments
segdur = dur/3
midpoint1 = start + (segdur/2)
midpoint2 = start + segdur + (segdur/2)
midpoint3 = start + (segdur*2) + (segdur/2)
# get pitch at each midpoint
Move cursor to: midpoint1
pitch1 = Get pitch... midpoint1
Move cursor to: midpoint2
pitch1 = Get pitch... midpoint2
Move cursor to: midpoint3
pitch1 = Get pitch... midpoint3
# Save result to text file:
resultline$ = "'soundname$' 'label$' 'midpoint1' 'midpoint2' 'midpoint3' 'pitch1' 'pitch2' 'pitch3''newline$'"
fileappend "'resultfile$'" 'resultline$'
select TextGrid 'soundname$'
endif
endfor
# Remove the TextGrid object from the object list
select TextGrid 'soundname$'
Remove
endif
# Remove the temporary objects from the object list
select Sound 'soundname$'
plus Pitch 'soundname$'
Remove
select Strings list
endfor
Remove
这应该工作。你可以发布MWE吗? – Stefano
您的代码示例不完整:它缺少'GetTier'过程的定义和初始表单 – jja