forked from stylerw/styler_praat_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextgrid_helperv3.praat
101 lines (94 loc) · 3.15 KB
/
textgrid_helperv3.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Grid Assistant
# Will Styler - 2015
#
# This script will just open all files in a folder and generate textgrids
#
# This makes the script great for cleaning and reviewing stimuli.
# If you change the below "0" to a "1", it'll open all files, whether already gridded or not. This is great for reviewing your work.
viewall = 0
directory$ = chooseDirectory$ ("Choose the directory containing sound files for gridding")
directory$ = "'directory$'" + "/"
file_type$ = ".wav"
Create Strings as file list... list 'directory$'*'file_type$'
number_files = Get number of strings
label restart
for ifile to number_files
select Strings list
sound$ = Get string... ifile
Read from file... 'directory$''sound$'
soundname$ = selected$ ("Sound", 1)
gridfile$ = "'directory$''soundname$'.TextGrid"
badfile$ = "'directory$''soundname$'.isBad"
if fileReadable (gridfile$)
selectObject: "Sound 'soundname$'"
if viewall = 1
Filter (pass Hann band): 0, 5000, 100
Scale intensity: 70
Read from file... 'directory$''soundname$'.TextGrid
selectObject: "Sound 'soundname$'_band"
plusObject: "TextGrid 'soundname$'"
Edit
editor TextGrid 'soundname$'
beginPause ("If the sound file is fine, click OK. If the target is missing or otherwise bad , click Bad File")
skipstat = endPause ("Redo last", "Bad file!", "OK", 3)
endeditor
selectObject: "TextGrid 'soundname$'"
if skipstat == 2
Save as text file: "'directory$''soundname$'.isBad"
elsif skipstat == 3
Save as text file: "'directory$''soundname$'.TextGrid"
elsif skipstat == 1
lastgridfile$ = "'directory$''lastsound$'.TextGrid"
lastbadfile$ = "'directory$''lastsound$'.isBad"
deleteFile: lastgridfile$
deleteFile: lastbadfile$
selectObject: "Sound 'soundname$'"
plusObject: "Sound 'soundname$'_band"
plusObject: "TextGrid 'soundname$'"
Remove
goto restart
endif
lastsound$ = soundname$
endif
Remove
elif fileReadable (badfile$)
selectObject: "Sound 'soundname$'"
Remove
else
selectObject: "Sound 'soundname$'"
To TextGrid: "vowel", ""
selectObject: "Sound 'soundname$'"
Filter (pass Hann band): 0, 5000, 100
Scale intensity: 70
selectObject: "Sound 'soundname$'_band"
plusObject: "TextGrid 'soundname$'"
Edit
editor TextGrid 'soundname$'
beginPause ("If the sound file is fine, click OK. If the target is missing or otherwise bad , click Bad File")
skipstat = endPause ("Redo last", "Bad file!", "OK", 3)
endeditor
selectObject: "TextGrid 'soundname$'"
if skipstat == 2
Save as text file: "'directory$''soundname$'.isBad"
elsif skipstat == 3
Save as text file: "'directory$''soundname$'.TextGrid"
elsif skipstat == 1
lastgridfile$ = "'directory$''lastsound$'.TextGrid"
lastbadfile$ = "'directory$''lastsound$'.isBad"
deleteFile: lastgridfile$
deleteFile: lastbadfile$
selectObject: "Sound 'soundname$'"
plusObject: "Sound 'soundname$'_band"
plusObject: "TextGrid 'soundname$'"
Remove
goto restart
endif
selectObject: "Sound 'soundname$'"
plusObject: "Sound 'soundname$'_band"
plusObject: "TextGrid 'soundname$'"
Remove
lastsound$ = soundname$
endif
endfor
select Strings list
Remove