-
Notifications
You must be signed in to change notification settings - Fork 1
/
extractUtts.praat
41 lines (35 loc) · 1.08 KB
/
extractUtts.praat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# extractUtts.praat
# Extract utterances from longer wav file
# Written by Eleanor Chodroff
# Nov 6 2020
#################
dir$ = "/Users/xxx/xxx/Phonological Trains data/models/"
Create Strings as file list: "files", dir$ + "*.wav"
nFiles = Get number of strings
outdir$ = dir$ + "rhythm_extracts/"
for i from 1 to nFiles
selectObject: "Strings files"
filename$ = Get string: i
basename$ = filename$ - ".wav"
Read from file: dir$ + filename$
Read from file: dir$ + basename$ + ".TextGrid"
nInt = Get number of intervals: 3
for j from 1 to nInt
selectObject: "TextGrid " + basename$
label$ = Get label of interval: 3, j
if label$ != ""
start = Get start time of interval: 3, j
end = Get end time of interval: 3, j
Extract part: start, end, "no"
Save as text file: outdir$ + basename$ + "_" + string$(j) + ".TextGrid"
Remove
selectObject: "Sound " + basename$
Extract part: start, end, "rectangular", 1.0, "no"
Save as WAV file: outdir$ + basename$ + "_" + string$(j) + ".wav"
Remove
endif
endfor
select all
minusObject: "Strings files"
Remove
endfor