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.7.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: aligned_textgrid-0.7.7.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.1 Linux/6.8.0-1021-azure

File hashes

Hashes for aligned_textgrid-0.7.7.tar.gz
Algorithm Hash digest
SHA256 a57cc8c86cb0ec81842402e1e27273cec3d06fca345d4ecd215ffdbdae80a52f
MD5 30753ae103ddf8f34bf8a8b8aef81c87
BLAKE2b-256 ea656c0d135465122c751d6d7af9340e9a69ad1529ffeed439fdcab6f8cc871a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aligned_textgrid-0.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c6db0363e3799f771d235fd1f5bd1e11af164b257bd302e008ecff808f3b1117
MD5 d55c0bd3939dccfa93deb7f8ca97bee5
BLAKE2b-256 546745f30610a4d15fd8af2b1e8f6bde2029902805d1e71f4cd10d8c3ed96335

See more details on using hashes here.

Supported by

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