Package 'textgRid'

Title: Praat TextGrid Objects in R
Description: The software application Praat can be used to annotate waveform data (e.g., to mark intervals of interest or to label events). (See <http://www.fon.hum.uva.nl/praat/> for more information about Praat.) These annotations are stored in a Praat TextGrid object, which consists of a number of interval tiers and point tiers. An interval tier consists of sequential (i.e., not overlapping) labeled intervals. A point tier consists of labeled events that have no duration. The 'textgRid' package provides S4 classes, generics, and methods for accessing information that is stored in Praat TextGrid objects.
Authors: Patrick Reidy [aut, cre], Tobias Busch [ctb]
Maintainer: Patrick Reidy <[email protected]>
License: GPL-3
Version: 1.0.2
Built: 2025-02-26 03:45:10 UTC
Source: https://github.com/patrickreidy/textgrid

Help Index


Find intervals within an IntervalTier.

Description

Find intervals according to various search criteria.

Usage

findIntervals(tier, pattern = "*", from = -Inf, to = Inf,
  at = numeric(), stringsAsFactors = FALSE, ...)

Arguments

tier

An IntervalTier object.

pattern

A regular expression for matching interval labels. Default is '*' so that the search finds all intervals within [from, to].

from

A numeric, the earliest time from which to search for intervals. Default is -Inf so that the search includes the start of tier.

to

A numeric, the latest time to which to search for intervals. Default is Inf so that the search includes the end of tier.

at

A numeric, an exact time at which to find intervals. Default is numeric() so that intervals are searched within [from, to].

stringsAsFactors

A logical, default is FALSE.

...

optional arguments passed to grep.

Details

Default behavior of findIntervals is to search for intervals within [from, to]. If the at argument is a non-empty numeric vector, then this default behavior is overridden, and the tier is searched only at the time given by at.

Value

A data.frame whose rows correspond to the intervals found according to the search criteria, and whose columns are: $Index, $StartTime, $EndTime, $Label,

See Also

IntervalTier-class, grep


Find points within a PointTier.

Description

Find points according to various search criteria: e.g., that occur within a time range, whose labels match a pattern.

Usage

findPoints(tier, pattern = "*", from = -Inf, to = Inf,
  stringsAsFactors = FALSE, ...)

Arguments

tier

A PointTier object.

pattern

A regular expression for matching point labels. Default is '*' so that the search finds all points within [from, to].

from

A numeric, the earliest time from which to search for points. Default is -Inf so that the search includes the start of tier.

to

A numeric, the latest time to which to search for points. Default is Inf so that the search includes the end of tier.

stringsAsFactors

A logical, default is FALSE.

...

optional arguments passed to grep.

Value

A data.frame whose rows correspond to the points found according to the search criteria, and whose columns are: $Index, $Time, $Label.

See Also

PointTier-class, grep


Access the slots of IntervalTier objects.

Description

Functions for accessing the slots of an IntervalTier object.

Usage

intervalStartTimes(tier)

intervalEndTimes(tier)

intervalLabels(tier)

Arguments

tier

An IntervalTier object.

See Also

IntervalTier-class, IntervalTier-constructor, Tier-accessors


IntervalTier S4 class for Praat TextGrids.

Description

The IntervalTier class extends the Tier class. An IntervalTier object describes a sequence of non-overlapping labeled intervals. An interval's label is typically the annotation of some contiguous portion of waveform data (e.g., a phonetic segment or word in speech data).

Slots

name

A character string, the name of the Tier.

number

An integer, the number of the Tier within the TextGrid.

startTimes

A numeric vector, the start times of the intervals in the IntervalTier.

endTimes

A numeric vector, the end times of the intervals in the IntervalTier.

labels

A character vector, the labels of the intervals in the IntervalTier.

See Also

IntervalTier-constructor, IntervalTier-accessors, TextGrid-class, Tier-class


Create an instance of the IntervalTier class.

Description

An S4 generic and S4 methods for creating an IntervalTier object.

Usage

IntervalTier(praatText, ...)

## S4 method for signature 'character'
IntervalTier(praatText)

Arguments

praatText

A character vector, the lines of text from a .TextGrid file that define an IntervalTier.

...

optional arguments for multiple dispatch (in development).

Value

A IntervalTier object. Values for the tierName, tierNumber, startTimes, endTimes, and labels slots are parsed automatically from the praatText.

See Also

IntervalTier-class, IntervalTier-accessors


Access the slots of PointTier objects.

Description

Functions for accessing the slots of a PointTier object.

Usage

pointTimes(tier)

pointLabels(tier)

Arguments

tier

A PointTier object.

See Also

PointTier-class, PointTier-constructor, Tier-accessors


PointTier S4 class for Praat TextGrids.

Description

The PointTier class extends the Tier class. A PointTier object describes a sequence of labeled points in time. A point's label is typically the annotation of some event in waveform data (e.g., the onset of voicing in speech data).

Slots

name

A character string, the name of the Tier.

number

An integer, the number of the Tier within the TextGrid.

times

A numeric vector, the times of the points in the PointTier.

labels

A character vector, the labels of the points in the PointTier.

See Also

PointTier-constructor, PointTier-accessors, TextGrid-class, Tier-class


Create an instance of the PointTier class.

Description

An S4 generic and S4 methods for creating an PointTier object.

Usage

PointTier(praatText, ...)

## S4 method for signature 'character'
PointTier(praatText)

Arguments

praatText

A character vector, the lines of text from a .TextGrid file that define a PointTier.

...

optional arguments for multiple dispatch (in development).

Value

A PointTier object. Values for the tierName, tierNumber, times, and labels slots are parsed automatically from the praatText.

See Also

PointTier-class, PointTier-accessors


textgRid: Praat TextGrid Objects in R

Description

The software application Praat can be used to annotate waveform data (e.g., to mark intervals of interest or to label events). These annotations are stored in a Praat TextGrid object, which consists of a number of interval tiers and point tiers. An interval tier consists of sequential (i.e., not overlapping) labeled intervals. A point tier consists of labeled events that have no duration. The textgRid package provides S4 classes, generics, and methods for accessing information that is stored in Praat TextGrid objects.

S4 classes

Tier, IntervalTier, PointTier, TextGrid

S4 generics and methods

TextGrid() object constructor

Functions

findIntervals, findPoints


Access the slots of TextGrid objects.

Description

Functions for accessing the slots of a TextGrid object.

Usage

textGridStartTime(textGrid)

textGridEndTime(textGrid)

Arguments

textGrid

An TextGrid object.

See Also

TextGrid-class, TextGrid-constructor


Coerce to a data.frame.

Description

Coerce an IntervalTier, PointTier, or TextGrid object to a data.frame.

Usage

## S3 method for class 'IntervalTier'
as.data.frame(x, row.names = NULL, optional = FALSE,
  ..., stringsAsFactors = FALSE)

## S3 method for class 'PointTier'
as.data.frame(x, row.names = NULL, optional = FALSE,
  ..., stringsAsFactors = FALSE)

## S3 method for class 'TextGrid'
as.data.frame(x, row.names = NULL, optional = FALSE, ...,
  stringsAsFactors = FALSE)

Arguments

x

An IntervalTier, PointTier, or TextGrid object.

row.names

NULL or a character vector giving the row names for the returned data.frame. If NULL (the default), the rows of the returned data.frame are named numerically beginning at 1.

optional

A logical, default is FALSE. If TRUE, setting row names and converting column names is optional.

...

Additional optional arguments. (Only here for consistency with the generic.)

stringsAsFactors

A logical, default is FALSE.

Details

IntervalTiers and PointTiers are coerced by passing them to findIntervals() and findPoints(), respectively. Only intervals and points that have contentful, non-empty labels are returned after coercion.

Value

A data.frame object whose rows represent the contentful intervals or points within object, and whose columns are: TierNumber, TierName, TierType, Index, StartTime, EndTime, Label.


TextGrid S4 class for Praat TextGrids.

Description

The TextGrid class extends the list class. A TextGrid object is essentially a list of IntervalTier and PointTier objects.

Slots

.Data

A list of IntervalTier and PointTier objects.

startTime

A numeric, the start time of the TextGrid.

endTime

A numeric, the end time of the TextGrid.

See Also

TextGrid-constructor, TextGrid-accessors, IntervalTier-class, PointTier-class


Create an instance of the TextGrid class.

Description

An S4 generic and S4 methods for creating a TextGrid object.

Usage

TextGrid(textGrid, ...)

## S4 method for signature 'character'
TextGrid(textGrid, encoding = NULL)

Arguments

textGrid

A character vector

...

optional arguments for multiple dispatch (in development).

encoding

The character encoding of the .TextGrid file. If NULL, then the encoding of the file is guessed using guess_encoding. Plausible encodings that might be used by Praat are "ASCII", "UTF-8", or "UTF-16BE" (if non-ASCII characters occur in the TextGrid).

Value

A TextGrid object.

Details for signature c(textGrid = 'character')

If textGrid is a string (i.e., a character vector with length(textGrid)=1), then it is assumed that the textGrid argument is the path to a .TextGrid file. Otherwise, the textGrid argument is assumed to be a character vector whose elements are the lines of some .TextGrid file.

See Also

TextGrid-class, TextGrid-accessors


Length of an IntervalTier or PointTier

Description

Get the number of intervals on an IntervalTier or the number of points on a PointTier.

Usage

## S3 method for class 'IntervalTier'
length(x)

## S3 method for class 'PointTier'
length(x)

Arguments

x

An IntervalTier or PointTier object.

Details

length.IntervalTier() checks that the vectors stored in the startTimes, endTimes, and labels slots of the IntervalTier object all have the same length. If so, the length of the labels-vector is returned; otherwise, NULL is returned.

length.PointTier() checks that the vectors stored in the times and labels slots of the PointTier object both have the same length. If so, the length of the labels-vector is returned; otherwise, NULL is returned.

Value

A numeric. The number of intervals or points on x.


Methods for Tier objects.

Description

Get the values of slots in a Tier object.

Usage

tierName(tier)

tierNumber(tier)

Arguments

tier

A Tier object.

See Also

Tier-class


Tier S4 class for Praat TextGrids.

Description

The Tier class is extended by the PointTier and IntervalTier classes. As such, the Tier class encapsulates only very general information that is common to both subtypes of tier-like object.

Slots

name

A character string, the name of the Tier.

number

An integer, the number of the Tier within the TextGrid.

See Also

IntervalTier-class, PointTier-class, TextGrid-class, Tier-accessors


Write Praat-compatible TextGrid.

Description

Convert a TextGrid object to a Praat-compatible character string and (optionally) write it to a file.

Usage

writeTextGrid(x, path = NULL, ...)

Arguments

x

A TextGrid object to be written.

path

Either a character string naming a file to write to, a connection open for writing, or NULL (default) for no output. When writing to file or connection, path is passed on as the con argument to writeLines

...

Additional arguments passed on to writeLines when writing to a file or connection.

Value

A character vector, Each element is one row of the TextGrid file.

See Also

TextGrid-class