textgrid
textgrid copied to clipboard
IntervalTier.intervalContaining(time), if index = 0 ,return None
class IntervalTier(object) def intervalContaining(self, time): i = self.indexContaining(time) if i : return self.intervals[i]
indexContaining return 0, ‘ if 0 ’ return false ,then return None。 but must return intervals[0]
This is too cryptic for me to interpret. Can you state clearly what the issue is?
This is one part of your script (see below).
class IntervalTier(object)
def intervalContaining(self, time):
i = self.indexContaining(time)
if i :
return self.intervals[i]
For this part of script, I think there is something wrong.
test.zip Based on your script, I wrote an example script named test.py. And I created a TextGrid file named data.TextGrid. The files of test.py and data.TextGrid are in the attachment. You can run test.py with data.TextGrid, then you will find what is wrong.
In data.TextGrid, in the first tier there are two intervals. The first interval is from 0 to 1.04s and the second interval is from 1.04 to 5s. In test.py, for the command, itv = tg.tiers[0].intervalContaining(0.2), I want to find which interval is at 0.2s in the first tier. The problem is: When I run test.py, the result turns out to be NONE. It means there is no interval at 0.2s. I think the result is wrong and the correct result should be the 1st interval in the first tier. So, I think there is something wrong with your script.
I'm sorry, I still don't understand the example. Can you give actual code (e.g., with an assert statement that shows what you expect to happen), or better yet, file a pull request that gives the behavior you want?