Read a textgrid file into a tibble
read_textgrid(path, file = NULL, encoding = NULL)read_textgrid_lines(lines, file = NULL)
legacy_read_textgrid(path, file = NULL, encoding = NULL)
legacy_read_textgrid_lines(lines, file = NULL)
a tibble with one row per textgrid annotation
a path to a textgrid
an optional value to use for the file column. For
read_textgrid(), the default is the base filename of the input file. For
read_textgrid_lines(), the default is NA.
the encoding of the textgrid. The default value NULL uses
readr::guess_encoding() to guess the encoding of the textgrid. If an
encoding is provided, it is forwarded to [readr::locale()] and
[readr::read_lines()].
alternatively, the lines of a textgrid file
The legacy_read_textgrid functions are the original textgrid
parsers provided by the package. They assume that the TextGrid file is a
"long" format textgrid; this is the default format used by "Save a text
file..." in Praat.
The current read_textgrid() functions are more
flexible and can read in "short" format textgrids and textgrids with
comments.
See https://www.fon.hum.uva.nl/praat/manual/TextGrid_file_formats.html
for a description of the textgrid file format. Note that this package does
not strictly adhere to format as described in this document. For example,
the document says that numbers should be freestanding (surrounded by spaces
or string boundaries), but Praat.exe can handle malformed numbers like
100ms. Therefore, we tried to implement a parser that matched what Praat
actually handles.
tg <- system.file("Mary_John_bell.TextGrid", package = "readtextgrid")
read_textgrid(tg)
Run the code above in your browser using DataLab