Skip to content

Commit

Permalink
Added schematic script demonstrating the extraction of info from othe…
Browse files Browse the repository at this point in the history
…r grids
  • Loading branch information
stylerw committed Oct 11, 2015
1 parent 478c2a4 commit a4d11ee
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions textgrid_info_extractor.praat
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

0 comments on commit a4d11ee

Please sign in to comment.