rustling.textgrid#

TextGrid (Praat) file parsing.

Package Contents#

class rustling.textgrid.Interval#

A single interval within an IntervalTier.

property xmin: float#

Start time in seconds.

property xmax: float#

End time in seconds.

property text: str#

The annotation text.

class rustling.textgrid.Point#

A single point within a TextTier (PointTier).

property number: float#

Time in seconds.

property mark: str#

The annotation text.

class rustling.textgrid.IntervalTier#

An interval tier within a TextGrid file.

property name: str#

Tier name.

property xmin: float#

Start time in seconds.

property xmax: float#

End time in seconds.

property intervals: list[Interval]#

Intervals in this tier.

property tier_class: str#

always "IntervalTier".

Type:

Tier class

class rustling.textgrid.TextTier#

A text tier (PointTier) within a TextGrid file.

property name: str#

Tier name.

property xmin: float#

Start time in seconds.

property xmax: float#

End time in seconds.

property points: list[Point]#

Points in this tier.

property tier_class: str#

always "TextTier".

Type:

Tier class

class rustling.textgrid.TextGrid#

TextGrid (Praat) data reader.

classmethod from_strs(strs: Sequence[str], ids: Sequence[str] | None = None, parallel: bool = True) TextGrid#

Parse TextGrid data from in-memory strings.

classmethod from_files(paths: Sequence[str | os.PathLike[str]], *, parallel: bool = True) TextGrid#

Load TextGrid data from file paths.

classmethod from_dir(path: str | os.PathLike[str], *, match: str | None = None, extension: str = '.TextGrid', parallel: bool = True) TextGrid#

Recursively load TextGrid data from a directory.

classmethod from_zip(path: str | os.PathLike[str], *, match: str | None = None, extension: str = '.TextGrid', parallel: bool = True) TextGrid#

Load TextGrid data from a ZIP archive.

classmethod from_git(url: str, *, rev: str | None = None, depth: int | None = None, match: str | None = None, extension: str = '.TextGrid', cache_dir: str | os.PathLike[str] | None = None, force_download: bool = False, parallel: bool = True) TextGrid#

Load TextGrid data from a git repository.

classmethod from_url(url: str, *, match: str | None = None, extension: str = '.TextGrid', cache_dir: str | os.PathLike[str] | None = None, force_download: bool = False, parallel: bool = True) TextGrid#

Load TextGrid data from a URL.

property file_paths: list[str]#

Return the list of file paths.

property n_files: int#

Return the number of files.

tiers() list[list[IntervalTier | TextTier]]#

Return tiers as a list of lists, one list per file.

to_strs() list[str]#

Return TextGrid strings, one per file.

to_chat_strs(*, participants: Sequence[str] | None = None) list[str]#

Return CHAT format strings, one per file.

to_chat(*, participants: Sequence[str] | None = None) rustling.chat.CHAT#

Convert to a CHAT object.

to_chat_files(dir_path: str | os.PathLike[str], /, *, participants: Sequence[str] | None = None, filenames: Sequence[str] | None = None) None#

Write CHAT (.cha) files to a directory.

to_elan_strs() list[str]#

Return EAF XML strings, one per file.

to_elan() rustling.elan.ELAN#

Convert to an ELAN object.

to_elan_files(dir_path: str | os.PathLike[str], /, *, filenames: Sequence[str] | None = None) None#

Write ELAN (.eaf) files to a directory.

to_srt_strs(*, participants: Sequence[str] | None = None) list[str]#

Return SRT format strings, one per file.

to_srt(*, participants: Sequence[str] | None = None) rustling.srt.SRT#

Convert to an SRT object.

to_srt_files(dir_path: str | os.PathLike[str], /, *, participants: Sequence[str] | None = None, filenames: Sequence[str] | None = None) None#

Write SRT (.srt) files to a directory.

to_files(dir_path: str | os.PathLike[str], /, *, filenames: Sequence[str] | None = None) None#

Write TextGrid files to a directory.

append(other: TextGrid, /) None#

Append data from another TextGrid reader.

append_left(other: TextGrid, /) None#

Left-append data from another TextGrid reader, preserving order.

extend(others: Sequence[TextGrid], /) None#

Extend data from multiple TextGrid readers.

pop() TextGrid#

Remove and return the last file as a new TextGrid reader.

pop_left() TextGrid#

Remove and return the first file as a new TextGrid reader.

clear() None#

Remove all data from this reader.

rustling.textgrid.read_textgrid(path: str | os.PathLike[str], *, cls: type[TextGrid] = TextGrid) TextGrid#

Read TextGrid data.

Parameters:
  • path – Path to a .zip file, a local directory containing .TextGrid files, a single .TextGrid file, a git repository URL (ending in .git), or an HTTP/HTTPS URL.

  • cls – The class used to create the reader. Must be TextGrid or a subclass of it.

Returns:

A TextGrid instance.

Raises:
  • TypeError – If cls is not TextGrid or a subclass of it.

  • ValueError – If path does not point to a recognized source.