Learn R Programming

readtextgrid

readtextgrid parses Praat textgrids into tidy R dataframes.

Features

  • Simple: Minimal package with two core functions (read_textgrid() and read_textgrid_lines()).
  • Tidy: Returns rectangular tibbles ready for downstream processing with dplyr and tidyr.
  • Flexible: Supports both long and short textgrid file formats.
  • Fast: Uses a compiled C++ tokenizer for high-throughput parsing.

Installation

Install readtextgrid from CRAN:

install.packages("readtextgrid")

Development version. Install precompiled version of readtextgrid from R-universe:

install.packages(
  "readtextgrid", 
  repos = c("https://tjmahr.r-universe.dev", "https://cloud.r-project.org")
)

Basic usage

Here is the example textgrid created by Praat. It was created using New > Create TextGrid... with default settings in Praat.

This textgrid is bundled with this R package. We can locate the file with example_textgrid(). We read in the textgrid with read_textgrid().

library(readtextgrid)

# Locates path to an example textgrid bundled with this package
tg <- example_textgrid()

read_textgrid(path = tg)
#> # A tibble: 3 × 10
#>   file                    tier_num tier_name tier_type    tier_xmin tier_xmax
#>   <chr>                      <int> <chr>     <chr>            <dbl>     <dbl>
#> 1 Mary_John_bell.TextGrid        1 Mary      IntervalTier         0         1
#> 2 Mary_John_bell.TextGrid        2 John      IntervalTier         0         1
#> 3 Mary_John_bell.TextGrid        3 bell      TextTier             0         1
#>    xmin  xmax text  annotation_num
#>   <dbl> <dbl> <chr>          <int>
#> 1     0     1 ""                 1
#> 2     0     1 ""                 1
#> 3    NA    NA <NA>              NA

The dataframe contains one row per annotation: one row for each interval on an interval tier and one row for each point on a point tier. If a point tier has no points, it is represented with single row with NA values.

The columns encode the following information:

  • file filename of the textgrid. By default this column uses the filename in path. A user can override this value by setting the file argument in read_textgrid(path, file), which can be useful if textgrids are stored in speaker-specific folders.
  • tier_num the number of the tier (as in the left margin of Praat’s textgrid editor)
  • tier_name the name of the tier (as in the right margin of Praat’s textgrid editor)
  • tier_type the type of the tier. "IntervalTier" for interval tiers and "TextTier" for point tiers (this is the terminology used inside of the textgrid file format).
  • tier_xmin, tier_xmax start and end times of the tier in seconds
  • xmin, xmax start and end times of the textgrid interval or point tier annotation in seconds
  • text the text in the annotation
  • annotation_num the number of the annotation in that tier (1 for the first annotation, etc.)

Reading in directories of textgrids

Suppose we have data on multiple speakers with one folder of textgrids per speaker. As an example, this package has a folder called speaker_data bundled with it representing 5 five textgrids from 2 speakers.

Copy Link

Version

Install

install.packages('readtextgrid')

Monthly Downloads

254

Version

0.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Tristan Mahr

Last Published

October 27th, 2025

Functions in readtextgrid (0.2.0)

example_textgrid

Locate the path of an example textgrid file
pivot_textgrid_tiers

Pivot a textgrid into wide format, respecting nested tiers
read_textgrid

Read a textgrid file into a tibble
readtextgrid-package

readtextgrid: Read in a 'Praat' 'TextGrid' File