I'm trying to read from one TextGrid modify the text and put that
text into an interval of a new TextGrid. I'm getting an error when I try to insert it into the new TextGrid. I'm looking for certain text marked by the <s/>
and </s>
. And that is what I want to write to the new TextGrid.
Open long sound file... /Summer_recap.wav
To TextGrid... "word"
textGridToWriteTo$ = "Summer_recap"
textGridToReadFrom$ = "Summer_recap_old"
tGrid = Read from file: "Summer_recap_old.TextGrid"
numberOfIntervals = Get number of intervals: 1
for intervalNumber from 1 to numberOfIntervals
text$ = Get label of interval: 1, intervalNumber
if text$ <> ""
head$ = left$ (text$, 4)
tail$ = right$ (text$, 4)
if head$ = "<s/>" and tail$ = "</s>"
startTime = Get start point: 1, intervalNumber
endTime = Get end point: 1, intervalNumber
s$ = replace$ (text$, "<s/>", "", 1)
s$ = replace$ (s$, "</s>", "", 1)
select TextGrid 'textGridToWriteTo$'
Insert boundary... 1 startTime
# below is where the error occurs
Set interval text... 1 'test$'
Insert boundary... 1 endTime
select TextGrid 'textGridToReadFrom$'
endif
endfor