-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added schematic script demonstrating the extraction of info from othe…
…r grids
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Will Styler | ||
# TextGrid information extraction script | ||
# Gathers labels from other tiers on Textgrids | ||
# So if you want to find the label from another tier corresponding to the time of another tier | ||
|
||
|
||
grid$ = selected$ ("TextGrid") | ||
resultfile$ = "'grid$'_info.txt" | ||
|
||
header_row$ = "gridname" + tab$ + "segment" + tab$ + "previousword" + tab$ + "word" + tab$ + "duration" + tab$ + "intensity" + newline$ | ||
fileappend "'resultfile$'" 'header_row$' | ||
|
||
|
||
selectObject: "TextGrid 'grid$'" | ||
|
||
numint = Get number of intervals... 2 | ||
# Start the loop | ||
for i from 1 to numint | ||
label = "" | ||
selectObject: "TextGrid 'grid$'" | ||
label$ = Get label of interval: 2, 'i' | ||
if label$ <> "" | ||
vstart = Get start point: 2, 'i' | ||
vend = Get end point: 2, 'i' | ||
vdur = vend - vstart | ||
midpoint = vstart + (vdur/2) | ||
|
||
# Spit the results into a text file | ||
int1 = Get interval at time... 1 'midpoint' | ||
lab1$ = Get label of interval... 1 int1 | ||
# print "'vdur'" | ||
prevint = int1 - 1 | ||
labpre$ = Get label of interval... 1 'prevint' | ||
int3 = Get interval at time... 3 'midpoint' | ||
dur = Get label of interval... 3 'int3' | ||
int4 = Get interval at time... 4 'midpoint' | ||
intensity = Get label of interval... 4 'int4' | ||
result_row$ = "'grid$'" + tab$ + "'label$'" + tab$ + "'labpre$'" + tab$ + "'lab1$'" + tab$ + "'dur'" + tab$ + "'intensity'" + newline$ | ||
fileappend "'resultfile$'" 'result_row$' | ||
endif | ||
endfor | ||
|