Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
# Calculates the duration of all intervals of all the files in a specified folder.
# All you need is a set of TextGrid files.
# Author: Shigeto Kawahara
# Ver. 10/3/2010 (supercedes the previous versions)
form Calculate durations of labeled segments
sentence directory ./
endform
#Read all files in a folder
Create Strings as file list... gridlist 'directory$'/*.TextGrid
n = Get number of strings
for i to n
clearinfo
#Loop through files
select Strings gridlist
gridname$ = Get string... i
Read from file... 'directory$'/'gridname$'
soundname$ = selected$ ("TextGrid")
# We then calculate the durations
int=Get number of intervals... 1
for k from 1 to 'int'
select TextGrid 'soundname$'
label$ = Get label of interval... 1 'k'
if label$ <> ""
onset = Get starting point... 1 'k'
offset = Get end point... 1 'k'
Read from file... 'directory$'/'soundname$'.wav
Extract part: onset, offset, "rectangular", 1, "no" Save as WAV file: ... 'directory$'/'label$'.wav
endif
endfor
endfor
# clean up
select all
Remove