Annotate¶
ELAN, TextGrid and TSV export, and reading an .eaf back.
Three exports from one tree, and a reader so the export is not a dead end.
ELAN is the format the nesting actually fits, so it is the one with a reader. Praat
TextGrid flattens to interval tiers and TSV flattens further; both are conveniences for
tools that cannot read .eaf, and neither is expected to round-trip the hierarchy.
The .eaf links the full session video at session-time offsets, not excerpt clips.
An annotation made against a clip is on the clip's clock, and every use of it
afterwards has to remap --- correctly, in both directions, forever. Session time is the
only clock that stays comparable across levels and across the six recordings.
Round-trip beyond from_elan --- taking a student's corrected file back into a
Hierarchy complete with their own tiers --- is wanted eventually and not now. The
reader here exists so the writer can be tested, and is the seam that fuller import
attaches to.
to_elan ¶
to_elan(hierarchy, video, out, levels=None, nest=True, vocabularies=None)
Write an ELAN .eaf, one tier per level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hierarchy
|
Hierarchy
|
The levels to write. A level with no spans still gets its tier, so that a tier the annotator fills herself has the same name in every session instead of being created by hand. |
required |
video
|
Path to the FULL session video. Annotations are on the session clock. |
required | |
out
|
Path to write. |
required | |
levels
|
Which levels to write, or None for all of them. |
None
|
|
nest
|
bool
|
Nest each level inside the previous one. True is right for a hierarchy --- actions inside phrases inside parts --- and wrong for layers that merely coincide. Speech is not inside motion, laughter is not inside speech, and another researcher's reference tier is not inside anything of ours; nesting those asserts a containment that does not exist and stops the annotator drawing a span where she needs one. Defaults to True so nothing already exported changes. |
True
|
vocabularies
|
dict
|
Level name to the list of allowed values, written as ELAN
controlled vocabularies so the annotator picks from a dropdown. Free text
produces |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The file written. |
Source code in musicalgestures/_annotate.py
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
from_elan ¶
from_elan(path)
Read an .eaf back into a Hierarchy.
This exists so to_elan can be tested against something other than its own
output being well-formed, and is the seam a fuller importer attaches to.
Source code in musicalgestures/_annotate.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
to_textgrid ¶
to_textgrid(hierarchy, out, levels=None, xmax=None)
Write a Praat TextGrid with one interval tier per level.
Flattened: TextGrid has no nesting, so the hierarchy is exported as parallel tiers and the relationship between them is not carried. That is a property of the format and is stated rather than worked around.
Source code in musicalgestures/_annotate.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
to_tsv ¶
to_tsv(hierarchy, out, levels=None)
Write every span as a row, with what produced it and how sure it is.
The flattest export, and the one that carries the most: agreement travels here
even though TextGrid has nowhere to put it, so a boundary's status is not lost by
choosing a different tool.
Source code in musicalgestures/_annotate.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |