Skip to main content

Classes for defining sequential information from TextGrids

Project description

Aligned TextGrid

PyPI Build codecov Maintainability Build Docs DOI

The aligned-textgrid package provides a python interface for representing and operating on TextGrids produced by forced aligners like FAVE or the Montreal Forced Aligner. Classes provided by aligned-textgrid represent hierarchical and precedence relationships among data stored in TextGrid formats allowing for simplified and more accessible analysis of aligned speech data.

Example Use Cases

  • You want to quickly loop through the Phone tier of a Textgrid, and also access information about the word it is a part of.
  • You want to quickly loop over the Word tier of a Textgrid and quickly count how many phones it has.
  • You want to programmatically merge together adjacent Textgrid intervals.

For examples on how to use the pacakge, see the Usage pages.

Installation

To install aligned-textgrid using pip, run the following command in your terminal:

pip install aligned-textgrid

Not another TextGrid implementation

There are several other packages that parse Praat Textgrids, including

aligned-textgrid’s goal is to capture hierarchical and sequential relationships represented in many TextGrids, and to make them easilly accessible to users via an intuitive interface. The goal is that from any arbitrary location within a TextGrid, users can easilly access information with minimally defensive coding.

Example

As an example, we’ll read in a textgrid produced with forced alignment that contains a single speaker with a word and phone tier.

from aligned_textgrid import AlignedTextGrid, Word, Phone
tg = AlignedTextGrid(
    textgrid_path='doc_src/usage/resources/josef-fruehwald_speaker.TextGrid', 
    entry_classes=[Word, Phone]
    )

Then, we can access an arbitrary phone interval.

arbitrary_interval = tg[0].Phone[20]

From this aribitrary interval, we can access information about the intervals preceding and following with the .prev and .fol attributes.

print(arbitrary_interval.prev.label)
print(arbitrary_interval.label)
print(arbitrary_interval.fol.label)
R
EY1
N

We can also access information about the word this interval is nested within with the .inword attribute.

print(arbitrary_interval.inword.label)
raindrops

The object returned by .inword is just another interval, meaning we can access informaton about it’s context with the .prev and .fol attributes as well.

print(arbitrary_interval.inword.prev.label)
print(arbitrary_interval.inword.label)
print(arbitrary_interval.inword.fol.label)
strikes
raindrops
in

For more

You can also directly read up on the function and class references.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aligned_textgrid-0.7.6.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

aligned_textgrid-0.7.6-py3-none-any.whl (52.8 kB view details)

Uploaded Python 3

File details

Details for the file aligned_textgrid-0.7.6.tar.gz.

File metadata

  • Download URL: aligned_textgrid-0.7.6.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for aligned_textgrid-0.7.6.tar.gz
Algorithm Hash digest
SHA256 bef6f84d59f4de45f7a75fc7d1803de5846c62862bed314de3ea2a2a62cb3b2f
MD5 f5b036df1054febc1b8725a13ec397a9
BLAKE2b-256 721801602dc73cb9be93660b45b07731de274bfb5335a7c42b7e43a06c38e578

See more details on using hashes here.

File details

Details for the file aligned_textgrid-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: aligned_textgrid-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 52.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for aligned_textgrid-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0d36d1f83baae4886e3199363c29add3b51a9bc58cd362187fb61bcd31020d7d
MD5 1415429fd91b1e0efe751129a62bd510
BLAKE2b-256 55c3a6a33707eb899b5391b9a77d35834a18c26e8b02c6cc1ce53604019530e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page