{"id":27153,"library":"monotonic-alignment-search","title":"Monotonic Alignment Search","description":"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.","status":"active","version":"0.2.1","language":"python","source_language":"en","source_url":"https://github.com/eginhard/monotonic_alignment_search","tags":["monotonic-alignment","text-to-speech","tts","glow-tts","alignment"],"install":[{"cmd":"pip install monotonic-alignment-search","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"PyTorch backend required for tensor operations","package":"torch","optional":true},{"reason":"NumPy backend as alternative to PyTorch","package":"numpy","optional":true}],"imports":[{"note":"Old import from Glow-TTS; 'mas' is not a package here.","wrong":"from mas import maximum_path","symbol":"maximum_path","correct":"from monotonic_alignment_search import maximum_path"},{"note":"Only available since v0.1.1; use for NumPy backend.","wrong":"","symbol":"maximum_path_numpy","correct":"from monotonic_alignment_search import maximum_path_numpy"}],"quickstart":{"code":"import torch\nfrom monotonic_alignment_search import maximum_path\n\n# Example: random hard attention (batch=1, 1 source, 5 target, no mask)\nattn_hard = torch.rand(1, 1, 1, 5).cumsum(3).round().long()\n# Perform MAS\npath = maximum_path(attn_hard, attn_hard.new_zeros(attn_hard.shape))\nprint(path.shape)  # torch.Size([1, 1, 1, 5])\n","lang":"python","description":"Perform monotonic alignment search on a random hard attention matrix using PyTorch."},"warnings":[{"fix":"Ensure your attention matrix is monotonic and non-negative before calling maximum_path.","message":"Input attention must be non-negative and monotonic; the algorithm does not enforce this. Incorrect inputs may produce silent failures or suboptimal alignments.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Prefer the PyTorch backend (maximum_path) for stability. If you need NumPy, pin to v0.1.1.","message":"NumPy backend (maximum_path_numpy) was experimental in v0.1.1 and may be removed in a future release.","severity":"deprecated","affected_versions":"0.1.1"},{"fix":"Install PyTorch separately according to your hardware (CPU/CUDA) before using this package.","message":"PyTorch backend removed or renamed? Not yet, but the v0.2.0 allowed choosing CPU/GPU; ensure your PyTorch installation is compatible.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install monotonic-alignment-search","cause":"Package not installed or installed under a different name.","error":"ModuleNotFoundError: No module named 'monotonic_alignment_search'"},{"fix":"Use maximum_path (PyTorch backend) instead. If you need NumPy, downgrade to v0.1.1: pip install 'monotonic-alignment-search==0.1.1'","cause":"Attempting to use NumPy backend on v0.2.0+ where it was potentially removed or renamed.","error":"ImportError: cannot import name 'maximum_path_numpy' from 'monotonic_alignment_search'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}