Pickling Aligned TextGrids

Due to the number of dynamically created classes, the default python pickle library doesn’t currently work for AlignedTextGrids. However, the cloudpickle library does.

from aligned_textgrid import AlignedTextGrid, custom_classes

tg = AlignedTextGrid(
    textgrid_path="../resources/josef-fruehwald_speaker.TextGrid",
    entry_classes=custom_classes(["Word", "Phone"])
)
import cloudpickle
from pathlib import Path
out_file = Path("test.pickle")
with out_file.open('wb') as f:
    cloudpickle.dump(tg, f)
with out_file.open('rb') as f:
    new_tg = cloudpickle.load(f)

Reuse

GPLv3