python
from aligned_textgrid import AlignedTextGrid, custom_classes
from fave_syllabify import syllabify_tg
from pathlib import Path
May 2, 2024
This is a work in progress.
bash
Import classes and functions
python
Read in a textgrid
python
tg = AlignedTextGrid(
textgrid_path=Path(
"data",
"josef-fruehwald_speaker.TextGrid"
),
entry_classes=custom_classes(
["Word", "Phone"]
)
)
print(tg)
AlignedTextGrid with 1 groups named ['group_0'] each with [2] tiers. [['Word', 'Phone']]
Syllabify the textgrid
python
AlignedTextGrid with 1 groups named ['group_0'] each with [4] tiers. [['Word', 'Syllable', 'SylPart', 'Phone']]
Each syllable is labelled with its stress.
Each syllable contains its constituent parts in a flat hierarchy (there’s no rhyme constituent).
python
['onset', 'nucleus', 'coda']
Each constituent contains its relevant phone.
To quickly open, syllabify, and save the resulting textgrid (see also the aligned-textgrid docs)
python
# Get the relevant imports
from aligned_textgrid import AlignedTextGrid, custom_classes
from fave_syllabify import syllabify_tg
# Load the Word and Phone aligned textgrid
tg = AlignedTextGrid(
textgrid_path="data/josef-fruehwald_speaker.TextGrid",
entry_classes=custom_classes(
["Word", "Phone"]
)
)
# Syllabify (this modifies the tg object itself)
syllabify_tg(tg)
# Save the result
tg.save_textgrid(
save_path = "data/syllabified.TextGrid"
)