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 |
Find intervals according to various search criteria.
findIntervals(tier, pattern = "*", from = -Inf, to = Inf, at = numeric(), stringsAsFactors = FALSE, ...)
findIntervals(tier, pattern = "*", from = -Inf, to = Inf, at = numeric(), stringsAsFactors = FALSE, ...)
tier |
An |
pattern |
A regular expression for matching interval labels.
Default is |
from |
A numeric, the earliest time from which to search for intervals.
Default is |
to |
A numeric, the latest time to which to search for intervals.
Default is |
at |
A numeric, an exact time at which to find intervals.
Default is |
stringsAsFactors |
A logical, default is |
... |
optional arguments passed to |
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
.
A data.frame
whose rows correspond to the intervals found
according to the search criteria, and whose columns are:
$Index
, $StartTime
, $EndTime
, $Label
,
Find points according to various search criteria: e.g., that occur within a time range, whose labels match a pattern.
findPoints(tier, pattern = "*", from = -Inf, to = Inf, stringsAsFactors = FALSE, ...)
findPoints(tier, pattern = "*", from = -Inf, to = Inf, stringsAsFactors = FALSE, ...)
tier |
A |
pattern |
A regular expression for matching point labels.
Default is |
from |
A numeric, the earliest time from which to search for points.
Default is |
to |
A numeric, the latest time to which to search for points.
Default is |
stringsAsFactors |
A logical, default is |
... |
optional arguments passed to |
A data.frame
whose rows correspond to the points found
according to the search criteria, and whose columns are:
$Index
, $Time
, $Label
.
Functions for accessing the slots of an IntervalTier
object.
intervalStartTimes(tier) intervalEndTimes(tier) intervalLabels(tier)
intervalStartTimes(tier) intervalEndTimes(tier) intervalLabels(tier)
tier |
An |
IntervalTier-class
,
IntervalTier-constructor
, Tier-accessors
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).
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.
IntervalTier-constructor
,
IntervalTier-accessors
, TextGrid-class
,
Tier-class
An S4 generic and S4 methods for creating an IntervalTier
object.
IntervalTier(praatText, ...) ## S4 method for signature 'character' IntervalTier(praatText)
IntervalTier(praatText, ...) ## S4 method for signature 'character' IntervalTier(praatText)
praatText |
A character vector, the lines of text from a
|
... |
optional arguments for multiple dispatch (in development). |
A IntervalTier
object. Values for the
tierName
, tierNumber
, startTimes
, endTimes
,
and labels
slots are parsed automatically from the praatText
.
IntervalTier-class
, IntervalTier-accessors
Functions for accessing the slots of a PointTier
object.
pointTimes(tier) pointLabels(tier)
pointTimes(tier) pointLabels(tier)
tier |
A |
PointTier-class
,
PointTier-constructor
, Tier-accessors
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).
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.
PointTier-constructor
,
PointTier-accessors
, TextGrid-class
,
Tier-class
An S4 generic and S4 methods for creating an PointTier
object.
PointTier(praatText, ...) ## S4 method for signature 'character' PointTier(praatText)
PointTier(praatText, ...) ## S4 method for signature 'character' PointTier(praatText)
praatText |
A character vector, the lines of text from a
|
... |
optional arguments for multiple dispatch (in development). |
A PointTier
object. Values for the
tierName
, tierNumber
, times
, and labels
slots are parsed automatically from the praatText
.
PointTier-class
, PointTier-accessors
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.
Tier
,
IntervalTier
,
PointTier
,
TextGrid
TextGrid() object constructor
Functions for accessing the slots of a TextGrid
object.
textGridStartTime(textGrid) textGridEndTime(textGrid)
textGridStartTime(textGrid) textGridEndTime(textGrid)
textGrid |
An |
TextGrid-class
,
TextGrid-constructor
Coerce an IntervalTier
, PointTier
, or TextGrid
object
to a data.frame
.
## 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)
## 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)
x |
An |
row.names |
|
optional |
A logical, default is |
... |
Additional optional arguments. (Only here for consistency with the generic.) |
stringsAsFactors |
A logical, default is |
IntervalTier
s and PointTier
s are coerced by passing them to
findIntervals()
and findPoints()
, respectively. Only intervals
and points that have contentful, non-empty labels are returned after coercion.
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
.
The TextGrid
class extends the list
class.
A TextGrid
object is essentially a list of
IntervalTier
and
PointTier
objects.
.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.
TextGrid-constructor
,
TextGrid-accessors
, IntervalTier-class
,
PointTier-class
An S4 generic and S4 methods for creating a TextGrid
object.
TextGrid(textGrid, ...) ## S4 method for signature 'character' TextGrid(textGrid, encoding = NULL)
TextGrid(textGrid, ...) ## S4 method for signature 'character' TextGrid(textGrid, encoding = NULL)
textGrid |
A character vector |
... |
optional arguments for multiple dispatch (in development). |
encoding |
The character encoding of the .TextGrid file. If |
A TextGrid
object.
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.
TextGrid-class
, TextGrid-accessors
Get the number of intervals on an IntervalTier
or the number of points
on a PointTier
.
## S3 method for class 'IntervalTier' length(x) ## S3 method for class 'PointTier' length(x)
## S3 method for class 'IntervalTier' length(x) ## S3 method for class 'PointTier' length(x)
x |
An |
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.
A numeric
. The number of intervals or points on x
.
Tier
objects.Get the values of slots in a Tier
object.
tierName(tier) tierNumber(tier)
tierName(tier) tierNumber(tier)
tier |
A |
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.
name
A character string, the name of the Tier.
number
An integer, the number of the Tier within the TextGrid.
IntervalTier-class
, PointTier-class
,
TextGrid-class
, Tier-accessors
Convert a TextGrid
object to a Praat-compatible character string and
(optionally) write it to a file.
writeTextGrid(x, path = NULL, ...)
writeTextGrid(x, path = NULL, ...)
x |
A |
path |
Either a character string naming a file to write to, a connection
open for writing, or |
... |
Additional arguments passed on to |
A character vector, Each element is one row of the TextGrid file.