Open
Description
We can parse TextGrid files saved in text but not binary format.
I do find some implementations that handle binary but looks like it might require some careful thinking about how to handle edge cases of low-level stuff I don't know well.
- convert existing test data to binary format with Praat
- borrow from the following implementation (that's MIT): https://github.com/dopefishh/pympi/blob/fc2f8718cf877bae6c70cedd09649df24bfdcc2c/pympi/Praat.py#L53
- might be helpful to consult this doc of the binary format: https://github.com/Legisign/Praat-textgrids/blob/master/Binary%20file%20format.txt that I will copy in here
# Header
b'ooBinaryFile\x08TextGrid' # where \x08 = len('TextGrid')
grid_xmin : double
grid_xmax : double
exists : bool
tiers : int
# Per Tier
str_len : byte
tier_type : str_len * byte
str_len : int
tier_name : str_len * byte
(tier_xmin : double) # discarded
(tier_xmax : double) # discarded
elements : int
# Per Point
xpos : double
str_len : short
str_len != -1:
text : str_len * byte
else:
# discard the -1
str_len : short
text : str_len * byte
# Per Interval
xmin : double
xmax : double
srt_len : short
str_len != -1:
text : str_len * Byte
else:
# discard the -1
str_len short
text : str_len * Byte