Registry / ai-ml / monotonic-alignment-search

monotonic-alignment-search

JSON →
library0.2.1pypypiunverified

Independent package implementing the monotonic alignment search algorithm from Glow-TTS for aligning text and speech. Currently at v0.2.1, supports PyTorch (CPU/GPU) and NumPy backends. Requires Python >=3.10.

pip install monotonic-alignment-search
INSTALL
IMPORT
SIG · MONOTONIC-ALIGNMEN
M
monotonic-alignment-search
ai-mlpythonv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

maximum_path
from monotonic_alignment_search import maximum_path
from monotonic_alignment_search import maximum_path

Perform monotonic alignment search on a random hard attention matrix using PyTorch.

import torch from monotonic_alignment_search import maximum_path # Example: random hard attention (batch=1, 1 source, 5 target, no mask) attn_hard = torch.rand(1, 1, 1, 5).cumsum(3).round().long() # Perform MAS path = maximum_path(attn_hard, attn_hard.new_zeros(attn_hard.shape)) print(path.shape) # torch.Size([1, 1, 1, 5])
Debug
Known issues
gotchaInput attention must be non-negative and monotonic; the algorithm does not enforce this. Incorrect inputs may produce silent failures or suboptimal alignments.
fix
Ensure your attention matrix is monotonic and non-negative before calling maximum_path.
affects: >=0.1.0
deprecatedNumPy backend (maximum_path_numpy) was experimental in v0.1.1 and may be removed in a future release.
fix
Prefer the PyTorch backend (maximum_path) for stability. If you need NumPy, pin to v0.1.1.
affects: 0.1.1
breakingPyTorch backend removed or renamed? Not yet, but the v0.2.0 allowed choosing CPU/GPU; ensure your PyTorch installation is compatible.
fix
Install PyTorch separately according to your hardware (CPU/CUDA) before using this package.
affects: >=0.2.0
Upgrade
Version history
0.2.1latest on PyPI · released Oct 15, 2025
Audit
Dependencies
torchoptionalPyTorch backend required for tensor operations
numpyoptionalNumPy backend as alternative to PyTorch
Agent activity
18 hits · last 30 days
node
16
Resources
monotonic-alignment-search — pip install monotonic-alignment-search · libregistry