pypar


Namepypar JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/maxrmorrison/pypar
SummaryPython phoneme alignment representation
upload_time2024-04-12 22:55:48
maintainerNone
docs_urlNone
authorMax Morrison
requires_pythonNone
licenseMIT
keywords align duration phoneme speech
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">Python phoneme alignment representation</h1>
<div align="center">

[![PyPI](https://img.shields.io/pypi/v/pypar.svg)](https://pypi.python.org/pypi/pypar)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://static.pepy.tech/badge/pypar)](https://pepy.tech/project/pypar)

`pip install pypar`
</div>

Word and phoneme alignment representation for speech tasks. This repo does
not perform forced word or phoneme alignment, but provides an interface
for working with the resulting alignment of a forced aligner, such as
[`pyfoal`](https://github.com/maxrmorrison/pyfoal), or a manual alignment.


## Table of contents

- [Usage](#usage)
    * [Creating alignments](#creating-aligments)
    * [Accessing words and phonemes](#accessing-words-and-phonemes)
    * [Saving alignments](#saving-alignments)
- [Application programming interface (API)](#application-programming-interface-api)
    * [`pypar.Alignment`](#pyparalignment)
        * [`pypar.Alignment.__init__`](#pyparalignment__init__)
        * [`pypar.Alignment.__add__`](#pyparalignment__add__)
        * [`pypar.Alignment.__eq__`](#pyparalignment__eq__)
        * [`pypar.Alignment.__getitem__`](#pyparalignment__getitem__)
        * [`pypar.Alignment.__len__`](#pyparalignment__len__)
        * [`pypar.Alignment.__str__`](#pyparalignment__str__)
        * [`pypar.Alignment.duration`](#pyparalignmentduration)
        * [`pypar.Alignment.end`](#pyparalignmentend)
        * [`pypar.Alignment.find`](#pyparalignmentfind)
        * [`pypar.Alignment.framewise_phoneme_indices`](#pyparalignmentframewise_phoneme_indices)
        * [`pypar.Alignment.phonemes`](#pyparalignmentphonemes)
        * [`pypar.Alignment.phoneme_at_time`](#pyparalignmentphoneme_at_time)
        * [`pypar.Alignment.phoneme_bounds`](#pyparalignmentphoneme_bounds)
        * [`pypar.Alignment.save`](#pyparalignmentsave)
        * [`pypar.Alignment.start`](#pyparalignmentstart)
        * [`pypar.Alignment.update`](#pyparalignmentupdate)
        * [`pypar.Alignment.words`](#pyparalignmentwords)
        * [`pypar.Alignment.word_bounds`](#pyparalignmentword_bounds)
    * [`pypar.Phoneme`](#pyparphoneme)
        * [`pypar.Phoneme.__init__`](#pyparphoneme__init__)
        * [`pypar.Phoneme.__eq__`](#pyparphoneme__eq__)
        * [`pypar.Phoneme.__str__`](#pyparphoneme__str__)
        * [`pypar.Phoneme.duration`](#pyparphonemeduration)
        * [`pypar.Phoneme.end`](#pyparphonemeend)
        * [`pypar.Phoneme.start`](#pyparphonemestart)
    * [`pypar.Word`](#pyparword)
        * [`pypar.Word.__init__`](#pyparword__init__)
        * [`pypar.Word.__eq__`](#pyparword__eq__)
        * [`pypar.Word.__getitem__`](#pyparword__getitem__)
        * [`pypar.Word.__len__`](#pyparword__len__)
        * [`pypar.Word.__str__`](#pyparword__str__)
        * [`pypar.Word.duration`](#pyparwordduration)
        * [`pypar.Word.end`](#pyparwordend)
        * [`pypar.Word.phoneme_at_time`](#pyparwordphoneme_at_time)
        * [`pypar.Word.start`](#pyparwordstart)
- [Tests](#tests)

## Usage

### Creating alignments

If you already have the alignment saved to a `json`, `mlf`, or `TextGrid`
file, pass the name of the file. Valid examples of each format can be found in
`test/assets/`.

```python
alignment = pypar.Alignment(file)
```

Alignments can be created manually from `Word` and `Phoneme` objects. Start and
end times are given in seconds.

```python
# Create a word from phonemes
word = pypar.Word(
    'THE',
    [pypar.Phoneme('DH', 0., .03), pypar.Phoneme('AH0', .03, .06)])

# Create a silence
silence = pypar.Word(pypar.SILENCE, pypar.Phoneme(pypar.SILENCE, .06, .16))

# Make an alignment
alignment = pypar.Alignment([word, silence])
```

You can create a new alignment from existing alignments via slicing and
concatenation.

```python
# Slice
first_two_words = alignment[:2]

# Concatenate
alignment_with_repeat = first_two_words + alignment
```


### Accessing words and phonemes

To retrieve a list of words in the alignment, use `alignment.words()`.
To retrieve a list of phonemes, use `alignment.phonemes()`. The `Alignment`,
`Word`, and `Phoneme` objects all define `.start()`, `.end()`, and
`.duration()` methods, which return the start time, end time, and duration,
respectively. All times are given in units of seconds. These objects also
define equality checks via `==`, casting to string with `str()`, and iteration
as follows.

```python
# Iterate over words
for word in alignment:

    # Access start and end times
    assert word.duration() == word.end() - word.start()

    # Iterate over phonemes in word
    for phoneme in word:

        # Access string representation
        assert isinstance(str(phoneme), str)
```

To access a word or phoneme at a specific time, pass the time in seconds to
`alignment.word_at_time` or `alignment.phoneme_at_time`.

To retrieve the frame indices of the start and end of a word or phoneme, pass
the audio sampling rate and hopsize (in samples) to `alignment.word_bounds` or
`alignment.phoneme_bounds`.


### Saving alignments

To save an alignment to disk, use `alignment.save(file)`, where `file` is the
desired filename. `pypar` currently supports saving as a `json` or `TextGrid`
file.


## Application programming interface (API)

### `pypar.Alignment`

#### `pypar.Alignment.__init__`

```python
def __init__(
    self,
    alignment: Union[str, bytes, os.PathLike, List[pypar.Word], dict]
) -> None:
    """Create alignment

    Arguments
        alignment
            The filename, list of words, or json dict of the alignment
    """
```


#### `pypar.Alignment.__add__`

```python
def __add__(self, other):
    """Add alignments by concatenation

    Arguments
        other
            The alignment to compare to

    Returns
        The concatenated alignment
    """
```


#### `pypar.Alignment.__eq__`

```python
def __eq__(self, other) -> bool:
    """Equality comparison for alignments

    Arguments
        other
            The alignment to compare to

    Returns
        Whether the alignments are equal
    """
```


#### `pypar.Alignment.__getitem__`

```python
def __getitem__(self, idx: Union[int, slice]) -> pypar.Word:
    """Retrieve the idxth word

    Arguments
        idx
            The index of the word to retrieve

    Returns
        The word at index idx
    """
```


#### `pypar.Alignment.__len__`

```python
def __len__(self) -> int:
    """Retrieve the number of words

    Returns
        The number of words in the alignment
    """
```


#### `pypar.Alignment.__str__`

```python
def __str__(self) -> str:
    """Retrieve the text

    Returns
        The words in the alignment separated by spaces
    """
```


#### `pypar.Alignment.duration`

```python
def duration(self) -> float:
    """Retrieve the duration of the alignment in seconds

    Returns
        The duration in seconds
    """
```


#### `pypar.Alignment.end`

```python
def end(self) -> float:
    """Retrieve the end time of the alignment in seconds

    Returns
        The end time in seconds
    """
```


#### `pypar.Alignment.framewise_phoneme_indices`

```python
def framewise_phoneme_indices(
    self,
    phoneme_map: Dict[str, int],
    hopsize: float,
    times: Optional[List[float]] = None
) -> List[int]:
    """Convert alignment to phoneme indices at regular temporal interval

    Arguments
        phoneme_map
            Mapping from phonemes to indices
        hopsize
            Temporal interval between frames in seconds
        times
            Specified times in seconds to sample phonemes
    """
```


#### `pypar.Alignment.find`

```python
def find(self, words: str) -> int:
    """Find the words in the alignment

    Arguments
        words
            The words to find

    Returns
        The index of the start of the words or -1 if not found
    """
```


#### `pypar.Alignment.phonemes`

```python
def phonemes(self) -> List[pypar.Phoneme]:
    """Retrieve the phonemes in the alignment

    Returns
        The phonemes in the alignment
    """
```


#### `pypar.Alignment.phoneme_at_time`

```python
def phoneme_at_time(self, time: float) -> Optional[pypar.Phoneme]:
    """Retrieve the phoneme spoken at specified time

    Arguments
        time
            Time in seconds

    Returns
        The phoneme at the given time (or None if time is out of bounds)
    """
```


#### `pypar.Alignment.phoneme_bounds`

```python
def phoneme_bounds(
    self,
    sample_rate: int,
    hopsize: int = 1
) -> List[Tuple[int, int]]:
    """Retrieve the start and end frame index of each phoneme

    Arguments
        sample_rate
            The audio sampling rate
        hopsize
            The number of samples between successive frames

    Returns
        The start and end indices of the phonemes
    """
```


#### `pypar.Alignment.save`

```python
def save(self, filename: Union[str, bytes, os.PathLike]) -> None:
    """Save alignment to json

    Arguments
        filename
            The location on disk to save the phoneme alignment json
    """
```


#### `pypar.Alignment.start`

```python
def start(self) -> float:
    """Retrieve the start time of the alignment in seconds

    Returns
        The start time in seconds
    """
```


#### `pypar.Alignment.update`

```python
def update(
    self,
    idx: int = 0,
    durations: Optional[List[float]] = None,
    start: Optional[float] = None
) -> None:
    """Update alignment starting from phoneme index idx

    Arguments
        idx
            The index of the first phoneme whose duration is being updated
        durations
            The new phoneme durations, starting from idx
        start
            The start time of the alignment
    """
```


#### `pypar.Alignment.words`

```python
def words(self) -> List[pypar.Word]:
    """Retrieve the words in the alignment

    Returns
        The words in the alignment
    """
```


#### `pypar.Alignment.word_bounds`

```python
def word_at_time(self, time: float) -> Optional[pypar.Word]:
    """Retrieve the word spoken at specified time

    Arguments
        time
            Time in seconds

    Returns
        The word spoken at the specified time
    """
```


### `pypar.Phoneme`

#### `pypar.Phoneme.__init__`

```python
def __init__(self, phoneme: str, start: float, end: float) -> None:
    """Create phoneme

    Arguments
        phoneme
            The phoneme
        start
            The start time in seconds
        end
            The end time in seconds
    """
```


#### `pypar.Phoneme.__eq__`

```python
def __eq__(self, other) -> bool:
    """Equality comparison for phonemes

    Arguments
        other
            The phoneme to compare to

    Returns
        Whether the phonemes are equal
    """
```


#### `pypar.Phoneme.__str__`

```python
def __str__(self) -> str:
    """Retrieve the phoneme text

    Returns
        The phoneme
    """
```


#### `pypar.Phoneme.duration`

```python
def duration(self) -> float:
    """Retrieve the phoneme duration

    Returns
        The duration in seconds
    """
```


#### `pypar.Phoneme.end`

```python
def end(self) -> float:
    """Retrieve the end time of the phoneme in seconds

    Returns
        The end time in seconds
    """
```


#### `pypar.Phoneme.start`

```python
def start(self) -> float:
    """Retrieve the start time of the phoneme in seconds

    Returns
        The start time in seconds
    """
```


### `pypar.Word`

#### `pypar.Word.__init__`

```python
def __init__(self, word: str, phonemes: List[pypar.Phoneme]) -> None:
    """Create word

    Arguments
        word
            The word
        phonemes
            The phonemes in the word
    """
```


#### `pypar.Word.__eq__`

```python
def __eq__(self, other) -> bool:
    """Equality comparison for words

    Arguments
        other
            The word to compare to

    Returns
        Whether the words are the same
    """
```


#### `pypar.Word.__getitem__`

```python
def __getitem__(self, idx: int) -> pypar.Phoneme:
    """Retrieve the idxth phoneme

    Arguments
        idx
            The index of the phoneme to retrieve

    Returns
        The phoneme at index idx
    """
```


#### `pypar.Word.__len__`

```python
def __len__(self) -> int:
    """Retrieve the number of phonemes

    Returns
        The number of phonemes
    """
```


#### `pypar.Word.__str__`

```python
def __str__(self) -> str:
    """Retrieve the word text

    Returns
        The word text
    """
```


#### `pypar.Word.duration`

```python
def duration(self) -> float:
    """Retrieve the word duration in seconds

    Returns
        The duration in seconds
    """
```


#### `pypar.Word.end`

```python
def end(self) -> float:
    """Retrieve the end time of the word in seconds

    Returns
        The end time in seconds
    """
```


#### `pypar.Word.phoneme_at_time`

```python
def phoneme_at_time(self, time: float) -> Optional[pypar.Phoneme]:
    """Retrieve the phoneme at the specified time

    Arguments
        time
            Time in seconds

    Returns
        The phoneme at the given time (or None if time is out of bounds)
    """
```


#### `pypar.Word.start`

```python
    def start(self) -> float:
        """Retrieve the start time of the word in seconds

        Returns
            The start time in seconds
        """
```


## Tests

Tests can be run as follows.

```
pip install pytest
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/maxrmorrison/pypar",
    "name": "pypar",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "align, duration, phoneme, speech",
    "author": "Max Morrison",
    "author_email": "maxrmorrison@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/92/bf/284d61e4b6ae0f3f4bf7e02194f869c5ec31cf631be3f9db9397cb76ddc6/pypar-0.0.6.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">Python phoneme alignment representation</h1>\n<div align=\"center\">\n\n[![PyPI](https://img.shields.io/pypi/v/pypar.svg)](https://pypi.python.org/pypi/pypar)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://static.pepy.tech/badge/pypar)](https://pepy.tech/project/pypar)\n\n`pip install pypar`\n</div>\n\nWord and phoneme alignment representation for speech tasks. This repo does\nnot perform forced word or phoneme alignment, but provides an interface\nfor working with the resulting alignment of a forced aligner, such as\n[`pyfoal`](https://github.com/maxrmorrison/pyfoal), or a manual alignment.\n\n\n## Table of contents\n\n- [Usage](#usage)\n    * [Creating alignments](#creating-aligments)\n    * [Accessing words and phonemes](#accessing-words-and-phonemes)\n    * [Saving alignments](#saving-alignments)\n- [Application programming interface (API)](#application-programming-interface-api)\n    * [`pypar.Alignment`](#pyparalignment)\n        * [`pypar.Alignment.__init__`](#pyparalignment__init__)\n        * [`pypar.Alignment.__add__`](#pyparalignment__add__)\n        * [`pypar.Alignment.__eq__`](#pyparalignment__eq__)\n        * [`pypar.Alignment.__getitem__`](#pyparalignment__getitem__)\n        * [`pypar.Alignment.__len__`](#pyparalignment__len__)\n        * [`pypar.Alignment.__str__`](#pyparalignment__str__)\n        * [`pypar.Alignment.duration`](#pyparalignmentduration)\n        * [`pypar.Alignment.end`](#pyparalignmentend)\n        * [`pypar.Alignment.find`](#pyparalignmentfind)\n        * [`pypar.Alignment.framewise_phoneme_indices`](#pyparalignmentframewise_phoneme_indices)\n        * [`pypar.Alignment.phonemes`](#pyparalignmentphonemes)\n        * [`pypar.Alignment.phoneme_at_time`](#pyparalignmentphoneme_at_time)\n        * [`pypar.Alignment.phoneme_bounds`](#pyparalignmentphoneme_bounds)\n        * [`pypar.Alignment.save`](#pyparalignmentsave)\n        * [`pypar.Alignment.start`](#pyparalignmentstart)\n        * [`pypar.Alignment.update`](#pyparalignmentupdate)\n        * [`pypar.Alignment.words`](#pyparalignmentwords)\n        * [`pypar.Alignment.word_bounds`](#pyparalignmentword_bounds)\n    * [`pypar.Phoneme`](#pyparphoneme)\n        * [`pypar.Phoneme.__init__`](#pyparphoneme__init__)\n        * [`pypar.Phoneme.__eq__`](#pyparphoneme__eq__)\n        * [`pypar.Phoneme.__str__`](#pyparphoneme__str__)\n        * [`pypar.Phoneme.duration`](#pyparphonemeduration)\n        * [`pypar.Phoneme.end`](#pyparphonemeend)\n        * [`pypar.Phoneme.start`](#pyparphonemestart)\n    * [`pypar.Word`](#pyparword)\n        * [`pypar.Word.__init__`](#pyparword__init__)\n        * [`pypar.Word.__eq__`](#pyparword__eq__)\n        * [`pypar.Word.__getitem__`](#pyparword__getitem__)\n        * [`pypar.Word.__len__`](#pyparword__len__)\n        * [`pypar.Word.__str__`](#pyparword__str__)\n        * [`pypar.Word.duration`](#pyparwordduration)\n        * [`pypar.Word.end`](#pyparwordend)\n        * [`pypar.Word.phoneme_at_time`](#pyparwordphoneme_at_time)\n        * [`pypar.Word.start`](#pyparwordstart)\n- [Tests](#tests)\n\n## Usage\n\n### Creating alignments\n\nIf you already have the alignment saved to a `json`, `mlf`, or `TextGrid`\nfile, pass the name of the file. Valid examples of each format can be found in\n`test/assets/`.\n\n```python\nalignment = pypar.Alignment(file)\n```\n\nAlignments can be created manually from `Word` and `Phoneme` objects. Start and\nend times are given in seconds.\n\n```python\n# Create a word from phonemes\nword = pypar.Word(\n    'THE',\n    [pypar.Phoneme('DH', 0., .03), pypar.Phoneme('AH0', .03, .06)])\n\n# Create a silence\nsilence = pypar.Word(pypar.SILENCE, pypar.Phoneme(pypar.SILENCE, .06, .16))\n\n# Make an alignment\nalignment = pypar.Alignment([word, silence])\n```\n\nYou can create a new alignment from existing alignments via slicing and\nconcatenation.\n\n```python\n# Slice\nfirst_two_words = alignment[:2]\n\n# Concatenate\nalignment_with_repeat = first_two_words + alignment\n```\n\n\n### Accessing words and phonemes\n\nTo retrieve a list of words in the alignment, use `alignment.words()`.\nTo retrieve a list of phonemes, use `alignment.phonemes()`. The `Alignment`,\n`Word`, and `Phoneme` objects all define `.start()`, `.end()`, and\n`.duration()` methods, which return the start time, end time, and duration,\nrespectively. All times are given in units of seconds. These objects also\ndefine equality checks via `==`, casting to string with `str()`, and iteration\nas follows.\n\n```python\n# Iterate over words\nfor word in alignment:\n\n    # Access start and end times\n    assert word.duration() == word.end() - word.start()\n\n    # Iterate over phonemes in word\n    for phoneme in word:\n\n        # Access string representation\n        assert isinstance(str(phoneme), str)\n```\n\nTo access a word or phoneme at a specific time, pass the time in seconds to\n`alignment.word_at_time` or `alignment.phoneme_at_time`.\n\nTo retrieve the frame indices of the start and end of a word or phoneme, pass\nthe audio sampling rate and hopsize (in samples) to `alignment.word_bounds` or\n`alignment.phoneme_bounds`.\n\n\n### Saving alignments\n\nTo save an alignment to disk, use `alignment.save(file)`, where `file` is the\ndesired filename. `pypar` currently supports saving as a `json` or `TextGrid`\nfile.\n\n\n## Application programming interface (API)\n\n### `pypar.Alignment`\n\n#### `pypar.Alignment.__init__`\n\n```python\ndef __init__(\n    self,\n    alignment: Union[str, bytes, os.PathLike, List[pypar.Word], dict]\n) -> None:\n    \"\"\"Create alignment\n\n    Arguments\n        alignment\n            The filename, list of words, or json dict of the alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.__add__`\n\n```python\ndef __add__(self, other):\n    \"\"\"Add alignments by concatenation\n\n    Arguments\n        other\n            The alignment to compare to\n\n    Returns\n        The concatenated alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.__eq__`\n\n```python\ndef __eq__(self, other) -> bool:\n    \"\"\"Equality comparison for alignments\n\n    Arguments\n        other\n            The alignment to compare to\n\n    Returns\n        Whether the alignments are equal\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.__getitem__`\n\n```python\ndef __getitem__(self, idx: Union[int, slice]) -> pypar.Word:\n    \"\"\"Retrieve the idxth word\n\n    Arguments\n        idx\n            The index of the word to retrieve\n\n    Returns\n        The word at index idx\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.__len__`\n\n```python\ndef __len__(self) -> int:\n    \"\"\"Retrieve the number of words\n\n    Returns\n        The number of words in the alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.__str__`\n\n```python\ndef __str__(self) -> str:\n    \"\"\"Retrieve the text\n\n    Returns\n        The words in the alignment separated by spaces\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.duration`\n\n```python\ndef duration(self) -> float:\n    \"\"\"Retrieve the duration of the alignment in seconds\n\n    Returns\n        The duration in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.end`\n\n```python\ndef end(self) -> float:\n    \"\"\"Retrieve the end time of the alignment in seconds\n\n    Returns\n        The end time in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.framewise_phoneme_indices`\n\n```python\ndef framewise_phoneme_indices(\n    self,\n    phoneme_map: Dict[str, int],\n    hopsize: float,\n    times: Optional[List[float]] = None\n) -> List[int]:\n    \"\"\"Convert alignment to phoneme indices at regular temporal interval\n\n    Arguments\n        phoneme_map\n            Mapping from phonemes to indices\n        hopsize\n            Temporal interval between frames in seconds\n        times\n            Specified times in seconds to sample phonemes\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.find`\n\n```python\ndef find(self, words: str) -> int:\n    \"\"\"Find the words in the alignment\n\n    Arguments\n        words\n            The words to find\n\n    Returns\n        The index of the start of the words or -1 if not found\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.phonemes`\n\n```python\ndef phonemes(self) -> List[pypar.Phoneme]:\n    \"\"\"Retrieve the phonemes in the alignment\n\n    Returns\n        The phonemes in the alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.phoneme_at_time`\n\n```python\ndef phoneme_at_time(self, time: float) -> Optional[pypar.Phoneme]:\n    \"\"\"Retrieve the phoneme spoken at specified time\n\n    Arguments\n        time\n            Time in seconds\n\n    Returns\n        The phoneme at the given time (or None if time is out of bounds)\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.phoneme_bounds`\n\n```python\ndef phoneme_bounds(\n    self,\n    sample_rate: int,\n    hopsize: int = 1\n) -> List[Tuple[int, int]]:\n    \"\"\"Retrieve the start and end frame index of each phoneme\n\n    Arguments\n        sample_rate\n            The audio sampling rate\n        hopsize\n            The number of samples between successive frames\n\n    Returns\n        The start and end indices of the phonemes\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.save`\n\n```python\ndef save(self, filename: Union[str, bytes, os.PathLike]) -> None:\n    \"\"\"Save alignment to json\n\n    Arguments\n        filename\n            The location on disk to save the phoneme alignment json\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.start`\n\n```python\ndef start(self) -> float:\n    \"\"\"Retrieve the start time of the alignment in seconds\n\n    Returns\n        The start time in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.update`\n\n```python\ndef update(\n    self,\n    idx: int = 0,\n    durations: Optional[List[float]] = None,\n    start: Optional[float] = None\n) -> None:\n    \"\"\"Update alignment starting from phoneme index idx\n\n    Arguments\n        idx\n            The index of the first phoneme whose duration is being updated\n        durations\n            The new phoneme durations, starting from idx\n        start\n            The start time of the alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.words`\n\n```python\ndef words(self) -> List[pypar.Word]:\n    \"\"\"Retrieve the words in the alignment\n\n    Returns\n        The words in the alignment\n    \"\"\"\n```\n\n\n#### `pypar.Alignment.word_bounds`\n\n```python\ndef word_at_time(self, time: float) -> Optional[pypar.Word]:\n    \"\"\"Retrieve the word spoken at specified time\n\n    Arguments\n        time\n            Time in seconds\n\n    Returns\n        The word spoken at the specified time\n    \"\"\"\n```\n\n\n### `pypar.Phoneme`\n\n#### `pypar.Phoneme.__init__`\n\n```python\ndef __init__(self, phoneme: str, start: float, end: float) -> None:\n    \"\"\"Create phoneme\n\n    Arguments\n        phoneme\n            The phoneme\n        start\n            The start time in seconds\n        end\n            The end time in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Phoneme.__eq__`\n\n```python\ndef __eq__(self, other) -> bool:\n    \"\"\"Equality comparison for phonemes\n\n    Arguments\n        other\n            The phoneme to compare to\n\n    Returns\n        Whether the phonemes are equal\n    \"\"\"\n```\n\n\n#### `pypar.Phoneme.__str__`\n\n```python\ndef __str__(self) -> str:\n    \"\"\"Retrieve the phoneme text\n\n    Returns\n        The phoneme\n    \"\"\"\n```\n\n\n#### `pypar.Phoneme.duration`\n\n```python\ndef duration(self) -> float:\n    \"\"\"Retrieve the phoneme duration\n\n    Returns\n        The duration in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Phoneme.end`\n\n```python\ndef end(self) -> float:\n    \"\"\"Retrieve the end time of the phoneme in seconds\n\n    Returns\n        The end time in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Phoneme.start`\n\n```python\ndef start(self) -> float:\n    \"\"\"Retrieve the start time of the phoneme in seconds\n\n    Returns\n        The start time in seconds\n    \"\"\"\n```\n\n\n### `pypar.Word`\n\n#### `pypar.Word.__init__`\n\n```python\ndef __init__(self, word: str, phonemes: List[pypar.Phoneme]) -> None:\n    \"\"\"Create word\n\n    Arguments\n        word\n            The word\n        phonemes\n            The phonemes in the word\n    \"\"\"\n```\n\n\n#### `pypar.Word.__eq__`\n\n```python\ndef __eq__(self, other) -> bool:\n    \"\"\"Equality comparison for words\n\n    Arguments\n        other\n            The word to compare to\n\n    Returns\n        Whether the words are the same\n    \"\"\"\n```\n\n\n#### `pypar.Word.__getitem__`\n\n```python\ndef __getitem__(self, idx: int) -> pypar.Phoneme:\n    \"\"\"Retrieve the idxth phoneme\n\n    Arguments\n        idx\n            The index of the phoneme to retrieve\n\n    Returns\n        The phoneme at index idx\n    \"\"\"\n```\n\n\n#### `pypar.Word.__len__`\n\n```python\ndef __len__(self) -> int:\n    \"\"\"Retrieve the number of phonemes\n\n    Returns\n        The number of phonemes\n    \"\"\"\n```\n\n\n#### `pypar.Word.__str__`\n\n```python\ndef __str__(self) -> str:\n    \"\"\"Retrieve the word text\n\n    Returns\n        The word text\n    \"\"\"\n```\n\n\n#### `pypar.Word.duration`\n\n```python\ndef duration(self) -> float:\n    \"\"\"Retrieve the word duration in seconds\n\n    Returns\n        The duration in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Word.end`\n\n```python\ndef end(self) -> float:\n    \"\"\"Retrieve the end time of the word in seconds\n\n    Returns\n        The end time in seconds\n    \"\"\"\n```\n\n\n#### `pypar.Word.phoneme_at_time`\n\n```python\ndef phoneme_at_time(self, time: float) -> Optional[pypar.Phoneme]:\n    \"\"\"Retrieve the phoneme at the specified time\n\n    Arguments\n        time\n            Time in seconds\n\n    Returns\n        The phoneme at the given time (or None if time is out of bounds)\n    \"\"\"\n```\n\n\n#### `pypar.Word.start`\n\n```python\n    def start(self) -> float:\n        \"\"\"Retrieve the start time of the word in seconds\n\n        Returns\n            The start time in seconds\n        \"\"\"\n```\n\n\n## Tests\n\nTests can be run as follows.\n\n```\npip install pytest\npytest\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python phoneme alignment representation",
    "version": "0.0.6",
    "project_urls": {
        "Homepage": "https://github.com/maxrmorrison/pypar"
    },
    "split_keywords": [
        "align",
        " duration",
        " phoneme",
        " speech"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "551f13e0dbd8acd4123750f19edee09ac7eeb8eebbdae836d24aa7abb353cd10",
                "md5": "52fe05adb26fd11cfacb72aea14b7bd3",
                "sha256": "11552805766a522a9b4631a52fc8388884ef7c7fcdfbf6501e95f8af6fc6fff1"
            },
            "downloads": -1,
            "filename": "pypar-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52fe05adb26fd11cfacb72aea14b7bd3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13926,
            "upload_time": "2024-04-12T22:55:46",
            "upload_time_iso_8601": "2024-04-12T22:55:46.961982Z",
            "url": "https://files.pythonhosted.org/packages/55/1f/13e0dbd8acd4123750f19edee09ac7eeb8eebbdae836d24aa7abb353cd10/pypar-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92bf284d61e4b6ae0f3f4bf7e02194f869c5ec31cf631be3f9db9397cb76ddc6",
                "md5": "1eafdc99cd6e67b6a4dbca6e0bba81f3",
                "sha256": "e69a3c3e974451ae29bf0889fb22b5b93ff17209f035dbdb63373a89f495e971"
            },
            "downloads": -1,
            "filename": "pypar-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "1eafdc99cd6e67b6a4dbca6e0bba81f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15385,
            "upload_time": "2024-04-12T22:55:48",
            "upload_time_iso_8601": "2024-04-12T22:55:48.504175Z",
            "url": "https://files.pythonhosted.org/packages/92/bf/284d61e4b6ae0f3f4bf7e02194f869c5ec31cf631be3f9db9397cb76ddc6/pypar-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 22:55:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maxrmorrison",
    "github_project": "pypar",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pypar"
}
        
Elapsed time: 1.08154s