crowsetta.formats.seq.textgrid.parse

crowsetta.formats.seq.textgrid.parse#

Functions for parsing TextGrid files.

Code for parsing TextGrids is adapted from several sources, all under MIT license. The main logic in parse_fp() is from <dopefishh/pympi> which is perhaps the most concise Python code I have found for parsing TextGrids. However there are also good ideas in kylebgorman/textgrid (__getitem__ method) and timmahrt/praatIO (data classes, handling encoding). For some documentation of the binary format see Legisign/Praat-textgrids and for a citable library with docs see hbuschme/TextGridTools but note that both of these have a GPL license.

Functions

get_float_from_next_line(fp)

Get next line from a text stream, search for a string that matches a float value, and return as a float.

get_int_from_next_line(fp)

Get next line from a text stream, search for a string that matches an int value, and return as an int.

get_str_from_next_line(fp)

Get next line from a text stream, search for a string as Praat writes them (with double quoting), and then return just that string.

parse(textgrid_path[, keep_empty])

Parse a TextGrid file, loading it into a dict.

parse_fp(fp[, keep_empty])

Parse a TextGrid file passed in as an open text stream, converting it to a dict.

search_next_line(fp, pat)

Get next line from a text stream and search it for a regex pattern.