Spaces:
Build error
Build error
Download modules/monotonic_align/__init__.py from amphion/NaturalSpeech2: direct link, hf CLI and curl.
- Browser
- Download file 691 Bytes
-
https://huggingface.co/spaces/amphion/NaturalSpeech2/resolve/main/modules/monotonic_align/__init__.py
- Command line
-
hf download hf://spaces/amphion/NaturalSpeech2/modules/monotonic_align/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/amphion/NaturalSpeech2/resolve/main/modules/monotonic_align/__init__.py
691 Bytes
| # This code from https://github.com/jaywalnut310/vits/ | |
| import numpy as np | |
| import torch | |
| from .monotonic_align.core import maximum_path_c | |
| def maximum_path(neg_cent, mask): | |
| """Cython optimized version. | |
| neg_cent: [b, t_t, t_s] | |
| mask: [b, t_t, t_s] | |
| """ | |
| device = neg_cent.device | |
| dtype = neg_cent.dtype | |
| neg_cent = neg_cent.data.cpu().numpy().astype(np.float32) | |
| path = np.zeros(neg_cent.shape, dtype=np.int32) | |
| t_t_max = mask.sum(1)[:, 0].data.cpu().numpy().astype(np.int32) | |
| t_s_max = mask.sum(2)[:, 0].data.cpu().numpy().astype(np.int32) | |
| maximum_path_c(path, neg_cent, t_t_max, t_s_max) | |
| return torch.from_numpy(path).to(device=device, dtype=dtype) | |