from aligned_textgrid import AlignedTextGrid
from aligned_textgrid import Word, Phone
Quickstart
The goal of this package is to make the hierarchical and precedence relationships in TextGrids produced by forced alignment accessable and leverageable for analysis or recoding. You can find a quickstart for reading in a TextGrid on this page.
Reading in a single speaker TextGrid
To quickly read in 2 tiered textgrid, like those produced by the Montreal Forced Aligner, import the AlignedTextGrid
class and the Word
and Phone
interval classes.
AlignedTextGrid
can take either a textgrid_path
argument, or a textgrid
argument for Textgrid objects that have already been created with praatio
.
= AlignedTextGrid(
reading_passage = "resources/josef-fruehwald_speaker.TextGrid",
textgrid_path =[Word, Phone]
entry_classes
) reading_passage
AlignedTextGrid with 1 groups, each with [2] tiers. [['Word', 'Phone']]
A list of each tier is available at index 0.
0] reading_passage[
TierGroup with 2 tiers. ['Word', 'Phone']
You can access the specific tiers within a TierGroup
with the name of the entry class.
0].Word reading_passage[
Sequence tier of Word; .superset_class: Top_wp; .subset_class: Phone
Multi-talker TextGrids
To read in a multi-talker textgrid, with the same Word
,Phone
organization for each speaker, the same approach works.
= AlignedTextGrid(
two_speaker = "resources/KY25A_1.TextGrid",
textgrid_path =[Word, Phone]
entry_classes
) two_speaker
AlignedTextGrid with 2 groups, each with [2, 2] tiers. [['Word', 'Phone'], ['Word', 'Phone']]
The first speakers’ tiers are available at index 0, and the second speakers tiers are available at index 1.
0] two_speaker[
TierGroup with 2 tiers. ['Word', 'Phone']
1] two_speaker[
TierGroup with 2 tiers. ['Word', 'Phone']
Accessing intervals
You can access intervals within a tier via ordinary indexing, looping, list comprehensions, etc.
for word in two_speaker[0].Word:
print(word.label)
yeah
well
now
you
might
start
that
i
was
born
in
eighteen
sixty
seven
nintey
three