【发布时间】:2015-08-05 07:44:10
【问题描述】:
这是我的第一个问题,我会尽力说清楚。我浏览了该网站,但没有找到任何可以帮助我的问题。
我正在尝试让 praat 中的发病检测脚本循环整个目录。我已将发病检测脚本作为内循环嵌套到遍历特定库中每个文件的外循环。但是,我似乎无法让它工作。我只得到我目录中第一个文件的开始。 发病检测脚本本身运行良好,外部循环与其他命令(例如“获取强度”)一起运行良好。 谁能看到我做错了什么?
这是我所做的:
form Get Intensity
sentence Directory .\
comment If you want to analyze all the files, leave this blank
word Base_file_name
comment The name of result file
text textfile intensity_VOT_list.txt
endform
#Print one set of headers
fileappend "'textfile$'" File name'tab$'
fileappend "'textfile$'" 'newline$'
Create Strings as file list... wavlist 'directory$'/'base_file_name$'*.wav
n = Get number of strings
for i from 1 to n
select Strings wavlist
filename$ = Get string... i
Read from file... 'directory$'/'filename$'
soundname$ = selected$ ("Sound")
To Intensity... 100 0
labelline$ = "'soundname$''tab$'"
fileappend "'textfile$'" 'labelline$'
select Intensity 'soundname$'
numberOfFrames = Get number of frames
fileappend "'textfile$'" 'numberOfFrames'
fileappend "'textfile$'" 'newline$'
for i from 1 to numberOfFrames
intensity = Get value in frame: i
if intensity > 40
time = Get time from frame: i
onsetresultline$ = "voice onset time for 'soundname$' is 'tab$''time''tab$'"
fileappend "'textfile$'" 'onsetresultline$'
fileappend "'textfile$'" 'newline$'
exit
endif
endfor
endfor
我很乐意提供任何帮助。如果您阅读了我的问题并觉得它的表述很糟糕,请给我反馈,以便我可以尝试变得更好。 好心
【问题讨论】:
-
您在第二个
for循环的末尾有一个exit语句。只要在任何声音中遇到值大于 40 的帧,您的脚本就会存在。此外,您使用了相同的控制变量 (i) 两次。您需要使用不同的变量。
标签: nested-loops praat