Navigating Sequences in a Tier

In addition to their hierarchical relationships, sequences also have relationships to the tiers they’re in.

from aligned_textgrid import AlignedTextGrid
from aligned_textgrid import Word, Phone

the_dog = AlignedTextGrid(
    textgrid_path="../resources/the_dog.TextGrid", 
    entry_classes=[Word, Phone]
    )
AH0 = the_dog.tier_groups[0].tier_list[1].sequence_list[1]
dog = the_dog.tier_groups[0].tier_list[0].sequence_list[1]

Accessing its tier

From a given sequence, we can access its tier with .intier

AH0.intier
Sequence tier of Phone; .superset_class: Word; .subset_class: Bottom_wp

We can also get its index within that tier.

AH0.tier_index
1

This allows for tier-level operations. For example, if we wanted to find the phone interval that occurs 0.5 seconds after the end of the current sequence interval, we could do so like this:

search_idx = AH0.intier.get_interval_at_time(AH0.end + 0.5)
AH0.intier[search_idx]
Class Phone, label: AO1, .superset_class: Word, .super_instance: dog, .subset_class: Bottom_wp

Tier-wise relationships

When a sequence interval is at the edge of a subset list (like, say, a phone within a word), its .fol attribute will reference a dummy boundary interval, even if there’s a following interval in its tier.

AH0.fol
Class Phone, label: #, .superset_class: Word, .super_instance, None, .subset_class: Bottom_wp
AH0.inword.fol[0]
Class Phone, label: D, .superset_class: Word, .super_instance: dog, .subset_class: Bottom_wp

However, you can access intervals an arbitrary distance away, tierwise, with .get_tierwise()

[AH0.get_tierwise(-1), AH0.get_tierwise(1), AH0.get_tierwise(2)]
[Class Phone, label: DH, .superset_class: Word, .super_instance: the, .subset_class: Bottom_wp,
 Class Phone, label: D, .superset_class: Word, .super_instance: dog, .subset_class: Bottom_wp,
 Class Phone, label: AO1, .superset_class: Word, .super_instance: dog, .subset_class: Bottom_wp]

Reuse

GPLv3