API
- class praattools.TextGrid(start, end, tiers=[])
A TextGrid object. Supports writing and reading from long and short TextGrid files.
A TextGrid is (currently) implemented as a
list
of Tiers. It will always support all list operations likeappend()
,insert()
, andpop()
.Initialise a TextGrid.
- Parameters:
- classmethod from_file(filename, encoding='utf-8')
Create a TextGrid from a file. Currently supports short and long text formats, but not (yet) binary.
- to_file(filename, format='long', encoding='utf-8')
Writes a TextGrid to a file. Currently supports short and long text formats, but not binary.
- Parameters:
- Raises:
ValueError – If encoding is not one of
'long'
,'short'
, or'binary'
.NotImplementedError – When called with
encoding='binary'
.
- __getitem__(index: SupportsIndex) Tier
- __getitem__(index: str) Tier
- __getitem__(index: slice) list[praattools.Tier]
A TextGrid can be indexed like a list or by name. Deleting is also implemented like this, but (re-)assignment can only be done by numeric index.
- class praattools.Tier(name, start, end, elements=[])
Not to be constructed separately. Base class for
IntervalTier
andPointTier
.Initialises a Tier.
- Parameters:
- class praattools.IntervalTier(name, start, end, elements=[])
An IntervalTier, consisting of
IntervalElement
s.IntervalTiers are (currently) implemented as a
list
of py:class:IntervalElements. They will always support all list operations likeappend()
,insert()
, andpop()
.Initialises a Tier.
- Parameters:
- element_type
alias of
IntervalElement
- class praattools.PointTier(name, start, end, elements=[])
A PointTier, or TextTier, of
PointElement
s.PointTiers are (currently) implemented as a
list
of py:class:PointElements. They will always support all list operations likeappend()
,insert()
, andpop()
.Initialises a Tier.
- Parameters:
- element_type
alias of
PointElement
- class praattools.IntervalElement(name, start, end)
An element in an
IntervalTier
.- Parameters:
name (str) – The interval name/mark.
start (float | timedelta) – The interval’s start time, in seconds or as a
datetime.timedelta
.end (float | timedelta) – The interval’s end time, in seconds or as a
datetime.timedelta
.