TextGrid and Tier Properties

There are a few useful pieces of information available at the AlignedTextGrid, TierGroups, and Tier levels

from aligned_textgrid import AlignedTextGrid
from aligned_textgrid import Word, Phone
two_speaker = AlignedTextGrid(
    textgrid_path = "../resources/KY25A_1.TextGrid",
    entry_classes= [Word, Phone]
)

Tier Names

# AlignedTextGrid level
two_speaker.tier_names
[['KY25A - words', 'KY25A - phones'], ['IVR - words', 'IVR - phones']]
# TierGroup level
two_speaker[0].tier_names
['KY25A - words', 'KY25A - phones']
# Tier level
two_speaker[0][0].name 
'KY25A - words'

xmin and xmax

# aligned textgrid level
[two_speaker.xmin, two_speaker.xmax]
[0.0, 26.774]
# tier groups level
[two_speaker[0].xmin, two_speaker[0].xmax]
[0.0, 26.774]
# tier level
[two_speaker[0][0].xmin, two_speaker[0][0].xmax]
[0.0, 26.774]

Entry Classes

# aligned text grid level
two_speaker.entry_classes
[[aligned_textgrid.sequences.word_and_phone.Word,
  aligned_textgrid.sequences.word_and_phone.Phone],
 [aligned_textgrid.sequences.word_and_phone.Word,
  aligned_textgrid.sequences.word_and_phone.Phone]]
# tier group level
two_speaker[0].entry_classes
[aligned_textgrid.sequences.word_and_phone.Word,
 aligned_textgrid.sequences.word_and_phone.Phone]
# tier level
two_speaker[0][0].entry_class
aligned_textgrid.sequences.word_and_phone.Word

Starts, ends and labels

These are only implemented at the tier level.

# every start time
two_speaker[0][0].starts
array([ 0.    , 10.7017, 11.0017, 13.3117, 13.6517, 13.9017, 13.9317,
       14.9717, 15.0017, 15.3117, 15.4517, 15.9417, 16.3217, 17.0217,
       17.2117, 17.3317, 17.7917, 18.0917, 18.9517, 19.7717, 20.2717,
       20.6417, 24.3517, 24.7317, 25.1717])
# every end time
two_speaker[0][0].ends
array([10.7017, 11.0017, 13.3117, 13.6517, 13.9017, 13.9317, 14.9717,
       15.0017, 15.3117, 15.4517, 15.9417, 16.3217, 17.0217, 17.2117,
       17.3317, 17.7917, 18.0917, 18.9517, 19.7717, 20.2717, 20.6417,
       24.3517, 24.7317, 25.1717, 26.774 ])
# every label
two_speaker[0][0].labels
['',
 'yeah',
 '',
 'well',
 'now',
 '',
 'you',
 '',
 'might',
 '',
 'start',
 'that',
 '',
 'i',
 'was',
 'born',
 'in',
 '',
 'eighteen',
 'sixty',
 'seven',
 '',
 'nintey',
 'three',
 '']

Reuse

GPLv3