Read a textgrid file into a tibble
Usage
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)Arguments
- path
a path to a textgrid
- file
an optional value to use for the
filecolumn. Forread_textgrid(), the default is the base filename of the input file. Forread_textgrid_lines(), the default isNA.- encoding
the encoding of the textgrid. The default value
NULLusesreadr::guess_encoding()to guess the encoding of the textgrid. If an encoding is provided, it is forwarded to[readr::locale()]and[readr::read_lines()].- lines
alternatively, the lines of a textgrid file
Details
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.
Examples
tg <- system.file("Mary_John_bell.TextGrid", package = "readtextgrid")
read_textgrid(tg)
#> # A tibble: 3 × 10
#> file tier_num tier_name tier_type tier_xmin tier_xmax xmin xmax text
#> <chr> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 Mary_John_… 1 Mary Interval… 0 1 0 1 ""
#> 2 Mary_John_… 2 John Interval… 0 1 0 1 ""
#> 3 Mary_John_… 3 bell TextTier 0 1 NA NA NA
#> # ℹ 1 more variable: annotation_num <int>
