0

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
user2743
  • 1,423
  • 3
  • 22
  • 34

1 Answers1

0

You actually have two problems. First, Set interval text... requires three arguments (tier number, interval number, text), but you've only got two. You can tell that it requires three arguments because the form that pops up when you click on that command in the Objects window requires three arguments. Second, you've got two ifs but only one endif.

Dan Villarreal
  • 119
  • 1
  • 12