Aligner - PyTorch
Sequence alignement methods with helpers for PyTorch.
Install
pip install aligner-pytorch
Usage
MAS
MAS (Monotonic Alignment Search) from GlowTTS. This can be used to get the alignment of any (similarity) matrix. Implementation in optimized Cython.
from aligner_pytorch import mas
sim = torch.rand(1, 4, 6) # [batch_size, x_length, y_length]
alignment = mas(sim)
"""
sim = tensor([[
[0.2, 0.8, 0.9, 0.9, 0.9, 0.4],
[0.6, 0.8, 0.9, 0.7, 0.1, 0.4],
[1.0, 0.4, 0.4, 0.2, 1.0, 0.7],
[0.1, 0.3, 0.1, 0.7, 0.6, 0.9]
]])
alignment = tensor([[
[1, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1]
]], dtype=torch.int32)
"""
XY Embedding to Alignment
Used during training to get the alignement of a x_embedding with y_embedding, computes the log probability from a normal distribution and the alignment with MAS.
from aligner_pytorch import get_alignment_from_embeddings
x_embedding = torch.randn(1, 4, 10)
y_embedding = torch.randn(1, 6, 10)
alignment = get_alignment_from_embeddings(
x_embedding=torch.randn(1, 4, 10), # [batch_size, x_length, features]
y_embedding=torch.randn(1, 6, 10), # [batch_size, y_length, features]
) # [batch_size, x_length, y_length]
"""
alignment = tensor([[
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1]
]], dtype=torch.int32)
"""
Duration Embedding to Alignment
Used during inference to compute the alignment from a trained duration embedding.
from aligner_pytorch import get_alignment_from_duration_embedding
alignment = get_alignment_from_duration_embedding(
embedding=torch.randn(1, 5), # Embedding: [batch_size, x_length]
scale=1.0, # Duration scale
y_length=10 # (Optional) fixes maximum output y_length
) # Output alignment [batch_size, x_length, y_length]
"""
alignment = tensor([[
[1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
]])
"""
Citations
Monotonic Alignment Search
@misc{2005.11129,
Author = {Jaehyeon Kim and Sungwon Kim and Jungil Kong and Sungroh Yoon},
Title = {Glow-TTS: A Generative Flow for Text-to-Speech via Monotonic Alignment Search},
Year = {2020},
Eprint = {arXiv:2005.11129},
}
Metadata
Release files for aligner-pytorch 0.0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aligner-pytorch-0.0.19.tar.gz | 108.5 kB | Without provenance | Details for aligner-pytorch-0.0.19.tar.gz |
Release files / aligner-pytorch-0.0.19.tar.gz
| Download URL | aligner-pytorch-0.0.19.tar.gz |
|---|---|
| Size | 108.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a7e41b3586aa062a91c8c3c0346275378fa896a96d81315c2b21d0c3d678804
|
|
BLAKE2b-256 checksum How to use checksums |
6ec32aa2dce18b99182a36df4fa8c24f2df72bb1da03c16374f6c1b368bc839b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Security for aligner-pytorch 0.0.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.