lacing.adapters.textgrid#
Praat TextGrid adapter.
Praat TextGrids have two tier types: IntervalTier (ranges) and
PointTier (instants — Praat’s own TextTier). lacing maps both to a
single Annotation envelope; point annotations use a zero-length
TimeInterval (start == end). See ANN-DOC §B and the
lacing-adapter-authoring skill.
- Lossy fields:
Praat has no provenance, no schema URIs, and no confidence. On load we synthesize provenance with
was_generated_by="adapter:textgrid". On dump we drop everything buttier,interval(or point), andbody['text'](or the rawbodyrepr if notextkey).- Time discipline:
Praat stores times as ASCII decimal strings — these can be exact at common rates. We convert through
Fraction(str)to avoid float ingestion. Default rate isDEFAULT_RATE(24000); passrate=to override.- Tier stereotype mapping:
ELAN tier stereotypes have no Praat equivalent. Every loaded tier gets stereotype
NONE. On dump, only thetiername is preserved.
Functions
|
Write a |
|
Load a TextGrid file or bytes into a |
- lacing.adapters.textgrid.dump(store, target=None, *, format='long_textgrid', include_empty=True, **_kwargs)[source]#
Write a
IntervalAnnotationStoreas a Praat TextGrid.- Parameters:
store (
IntervalAnnotationStore) – Source store. Only annotations with aMediaRefinterval are exported; timeless (AnnotationRefwithout sub-interval) annotations are silently dropped.target (
str|PathLike|None) – Output path. If None, returns bytes.format (
str) – One of praatio’s formats:"long_textgrid","short_textgrid","json".include_empty (
bool) – Whether to emit empty-label intervals on point tiers.
- Return type:
- lacing.adapters.textgrid.load(source, *, rate=24000, asset_id='textgrid:unspecified', attribution='anonymous', include_empty=True, **_kwargs)[source]#
Load a TextGrid file or bytes into a
MemoryStore.- Parameters:
source (
str|bytes|PathLike) – Path or bytes containing TextGrid content.rate (
int) – Quantization rate for converted times.asset_id (
str) –MediaRef.asset_idto attach to every annotation.attribution (
str) –Provenance.was_attributed_tovalue.include_empty (
bool) – If False, drop intervals/points with empty labels.
- Return type: