from aligned_textgrid import AlignedTextGrid
from aligned_textgrid import Word, Phone
TextGrid and Tier Properties
There are a few useful pieces of information available at the AlignedTextGrid, TierGroups, and Tier levels
= AlignedTextGrid(
two_speaker = "../resources/KY25A_1.TextGrid",
textgrid_path = [Word, Phone]
entry_classes )
Tier Names
# AlignedTextGrid level
two_speaker.tier_names
[['KY25A - words', 'KY25A - phones'], ['IVR - words', 'IVR - phones']]
# TierGroup level
0].tier_names two_speaker[
['KY25A - words', 'KY25A - phones']
# Tier level
0][0].name two_speaker[
'KY25A - words'
xmin and xmax
# aligned textgrid level
[two_speaker.xmin, two_speaker.xmax]
[0.0, 26.774]
# tier groups level
0].xmin, two_speaker[0].xmax] [two_speaker[
[0.0, 26.774]
# tier level
0][0].xmin, two_speaker[0][0].xmax] [two_speaker[
[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
0].entry_classes two_speaker[
[aligned_textgrid.sequences.word_and_phone.Word,
aligned_textgrid.sequences.word_and_phone.Phone]
# tier level
0][0].entry_class two_speaker[
aligned_textgrid.sequences.word_and_phone.Word
Starts, ends and labels
These are only implemented at the tier level.
# every start time
0][0].starts two_speaker[
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
0][0].ends two_speaker[
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
0][0].labels two_speaker[
['',
'yeah',
'',
'well',
'now',
'',
'you',
'',
'might',
'',
'start',
'that',
'',
'i',
'was',
'born',
'in',
'',
'eighteen',
'sixty',
'seven',
'',
'nintey',
'three',
'']
Reuse
GPLv3