| 1 |
# Buckeye.praat |
| 2 |
# Paul Boersma, 3 May 2025 |
| 3 |
|
| 4 |
# |
| 5 |
# This script cycles through all the sound files and annotations of the Buckeye corpus, |
| 6 |
# listing the following: |
| 7 |
# |
| 8 |
# - duration of the Sound |
| 9 |
# - duration of the TextGrid |
| 10 |
# |
| 11 |
|
| 12 |
form: "Report on Buckeye corpus" |
| 13 |
folder: "Buckeye folder", "/Volumes/Buckeye" |
| 14 |
endform |
| 15 |
|
| 16 |
corpusFolderPath$ = buckeye_folder$ |
| 17 |
writeInfoLine: "Reporting on the Buckeye folder “", corpusFolderPath$, "”..." |
| 18 |
|
| 19 |
stopwatch |
| 20 |
folderNames$# = folderNames$#: corpusFolderPath$ + "/s*" |
| 21 |
numberOfFolders = size (folderNames$#) |
| 22 |
assert numberOfFolders = 40 |
| 23 |
for ifolder to numberOfFolders |
| 24 |
folderName$ = folderNames$# [ifolder] |
| 25 |
folderPath$ = corpusFolderPath$ + "/" + folderName$ |
| 26 |
appendInfoLine: folderPath$ |
| 27 |
subfolderNames$# = folderNames$#: folderPath$ + "/*" |
| 28 |
numberOfSubfolders = size (subfolderNames$#) |
| 29 |
assert numberOfSubfolders >= 4 |
| 30 |
assert numberOfSubfolders <= 11 |
| 31 |
for isubfolder to numberOfSubfolders |
| 32 |
subfolderName$ = subfolderNames$# [isubfolder] |
| 33 |
subfolderPath$ = folderPath$ + "/" + subfolderName$ |
| 34 |
appendInfo: subfolderPath$ |
| 35 |
|
| 36 |
# |
| 37 |
# Read all the data. |
| 38 |
# |
| 39 |
soundFilePath$ = subfolderPath$ + "/" + subfolderName$ + ".wav" |
| 40 |
Read Sound with adjacent annotation files (Buckeye): soundFilePath$ |
| 41 |
assert numberOfSelected () = 2 |
| 42 |
assert selected$ (1) = "Sound " + subfolderName$ |
| 43 |
assert selected$ (2) = "TextGrid " + subfolderName$ |
| 44 |
|
| 45 |
# |
| 46 |
# Identify each of the two objects. |
| 47 |
# |
| 48 |
sound = selected ("Sound") |
| 49 |
textgrid = selected ("TextGrid") |
| 50 |
|
| 51 |
# |
| 52 |
# Run the "analyses." |
| 53 |
# |
| 54 |
selectObject: sound |
| 55 |
soundDuration = Get total duration |
| 56 |
selectObject: textgrid |
| 57 |
textgridDuration = Get total duration |
| 58 |
appendInfoLine: " ", soundDuration, " ", textgridDuration |
| 59 |
assert soundDuration - textgridDuration < 80.0 |
| 60 |
if textgridDuration - soundDuration > 1.5 |
| 61 |
appendInfoLine: "WARNING: the sound is ", textgridDuration - soundDuration, " seconds shorter than the annotation." |
| 62 |
endif |
| 63 |
|
| 64 |
# |
| 65 |
# Check grid structure. |
| 66 |
# |
| 67 |
numberOfTiers = Get number of tiers |
| 68 |
intendedTierNames$# = { "phon", "phon*", "words", "dict", "trans", "pos", "log" } |
| 69 |
assert size (intendedTierNames$#) = numberOfTiers |
| 70 |
for itier to numberOfTiers |
| 71 |
realizedTierName$ = Get tier name: itier |
| 72 |
assert realizedTierName$ = intendedTierNames$# [itier] |
| 73 |
endfor |
| 74 |
numberOfIntervalsOnTier1 = Get number of intervals: 1 |
| 75 |
numberOfIntervalsOnTier2 = Get number of intervals: 2 |
| 76 |
assert numberOfIntervalsOnTier1 = numberOfIntervalsOnTier2 |
| 77 |
numberOfIntervalsOnTier3 = Get number of intervals: 3 |
| 78 |
assert numberOfIntervalsOnTier3 < numberOfIntervalsOnTier1 |
| 79 |
for itier from 4 to 6 |
| 80 |
numberOfIntervals = Get number of intervals: itier |
| 81 |
assert numberOfIntervals = numberOfIntervalsOnTier3 |
| 82 |
endfor |
| 83 |
|
| 84 |
# |
| 85 |
# Perform redundancy checks on the TextGrid. |
| 86 |
# |
| 87 |
# First check: tier 3 predicts tiers 1, 2, 4, 5, 6 and 7. |
| 88 |
# |
| 89 |
numberOfIntervalsOnTier3 = Get number of intervals: 3 |
| 90 |
for iinterval to numberOfIntervalsOnTier3 |
| 91 |
text3$ = Get label of interval: 3, iinterval |
| 92 |
if left$ (text3$) = "<" |
| 93 |
tmin = Get start time of interval: 3, iinterval |
| 94 |
tmax = Get end time of interval: 3, iinterval |
| 95 |
if startsWith (text3$, "<VOCNOISE") or startsWith (text3$, "<VOCNIOSE") |
| 96 |
@checkIntervalTexts: "VOCNOISE", "", "U", "U", "null" |
| 97 |
elsif startsWith (text3$, "<SIL") |
| 98 |
@checkIntervalTexts: "SIL", "", "S", "S", "null" |
| 99 |
elsif startsWith (text3$, "<NOISE") or startsWith (text3$, "<NOSIE-") |
| 100 |
@checkIntervalTexts: "NOISE", "", "U", "U", "null" |
| 101 |
elsif startsWith (text3$, "<IVER>") |
| 102 |
@checkIntervalTexts: "IVER", "", "S", "S", "null" |
| 103 |
elsif startsWith (text3$, "<IVER-") or startsWith (text3$, "<IVER_") |
| 104 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 105 |
elsif startsWith (text3$, "<CUTOFF") or startsWith (text3$, "<cutoff") or startsWith (text3$, "<CUTTOFF") or startsWith (text3$, "<CUTFF") |
| 106 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 107 |
elsif startsWith (text3$, "<EXCLUDE") or startsWith (text3$, "<EXCL-") |
| 108 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 109 |
elsif startsWith (text3$, "<EXT") or startsWith (text3$, "<EXt-") |
| 110 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 111 |
elsif startsWith (text3$, "<HES") |
| 112 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 113 |
elsif startsWith (text3$, "<Hes") |
| 114 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 115 |
elsif startsWith (text3$, "<LAUGH") or startsWith (text3$, "<LAUH-") or startsWith (text3$, "<LAUCH-") or startsWith (text3$, "<LAULGH-") |
| 116 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 117 |
elsif startsWith (text3$, "<UNKNOWN") |
| 118 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 119 |
elsif startsWith (text3$, "<ERROR") |
| 120 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 121 |
elsif startsWith (text3$, "<previ=") |
| 122 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 123 |
elsif startsWith (text3$, "<oney=") |
| 124 |
@checkIntervalTexts: "IVER", "", "U", "U", "null" |
| 125 |
else |
| 126 |
exitScript: "Unknown text: ", text3$ |
| 127 |
endif |
| 128 |
elsif left$ (text3$) = "{" |
| 129 |
if text3$ = "{B_TRANS}" |
| 130 |
@checkIntervalTexts: "{B_TRANS}", "", "B", "B", "null" |
| 131 |
elsif text3$ = "{E_TRANS}" |
| 132 |
@checkIntervalTexts: "{E_TRANS}", "", "E", "E", "null" |
| 133 |
else |
| 134 |
exitScript: "Unknown text: ", text3$ |
| 135 |
endif |
| 136 |
endif |
| 137 |
endfor |
| 138 |
|
| 139 |
# |
| 140 |
# Look for combined intervals. |
| 141 |
# |
| 142 |
for itier from 1 to 6 |
| 143 |
numberOfIntervals = Get number of intervals: itier |
| 144 |
for iinterval to numberOfIntervals |
| 145 |
tmin = Get start time of interval: itier, iinterval |
| 146 |
tmax = Get end time of interval: itier, iinterval |
| 147 |
text$ = Get label of interval: itier, iinterval |
| 148 |
if index (text$, "//") |
| 149 |
appendInfoLine: "WARNING: combined text “", text$, |
| 150 |
... "” (between ", tmin, " and ", tmax, "), on tier ", itier, "." |
| 151 |
endif |
| 152 |
endfor |
| 153 |
endfor |
| 154 |
# |
| 155 |
# Clean up. |
| 156 |
# |
| 157 |
removeObject: sound, textgrid |
| 158 |
|
| 159 |
endfor |
| 160 |
endfor |
| 161 |
appendInfoLine: "Elapsed time: ", stopwatch, " seconds" |
| 162 |
|
| 163 |
procedure checkIntervalTexts: .expectedText1$, .expectedText2$, .expectedText4$, .expectedText5$, .expectedText6$ |
| 164 |
.realizedText4$ = Get label of interval: 4, iinterval |
| 165 |
.realizedText5$ = Get label of interval: 5, iinterval |
| 166 |
.realizedText6$ = Get label of interval: 6, iinterval |
| 167 |
if length (.realizedText4$) > 1 or not index (.expectedText4$, .realizedText4$) |
| 168 |
appendInfoLine: "WARNING: expected dict text “", .expectedText4$, "“, but found “", .realizedText4$, |
| 169 |
... "” (between ", tmin, " and ", tmax, "), for word ", text3$, "." |
| 170 |
endif |
| 171 |
if length (.realizedText5$) > 1 or not index (.expectedText5$, .realizedText5$) |
| 172 |
appendInfoLine: "WARNING: expected trans text “", .expectedText5$, "“, but found “", .realizedText5$, |
| 173 |
... "” (between ", tmin, " and ", tmax, "), for word ", text3$, "." |
| 174 |
endif |
| 175 |
if .realizedText6$ <> .expectedText6$ |
| 176 |
appendInfoLine: "WARNING: expected pos text “", .expectedText6$, "“, but found “", .realizedText6$, |
| 177 |
... "” (between ", tmin, " and ", tmax, "), for word ", text3$, "." |
| 178 |
endif |
| 179 |
endproc |