Spaces:
Runtime error
Runtime error
Download zonos/codebook_pattern.py from Hyathi/SoundImage-VoiceClone: direct link, hf CLI and curl.
- Browser
- Download file 441 Bytes
-
https://huggingface.co/spaces/Hyathi/SoundImage-VoiceClone/resolve/main/zonos/codebook_pattern.py
- Command line
-
hf download hf://spaces/Hyathi/SoundImage-VoiceClone/zonos/codebook_pattern.py
-
curl -L -o codebook_pattern.py https://huggingface.co/spaces/Hyathi/SoundImage-VoiceClone/resolve/main/zonos/codebook_pattern.py
441 Bytes
| import torch | |
| import torch.nn.functional as F | |
| def apply_delay_pattern(codes: torch.Tensor, mask_token: int): | |
| codes = F.pad(codes, (0, codes.shape[1]), value=mask_token) | |
| return torch.stack([codes[:, k].roll(k + 1) for k in range(codes.shape[1])], dim=1) | |
| def revert_delay_pattern(codes: torch.Tensor): | |
| _, n_q, seq_len = codes.shape | |
| return torch.stack([codes[:, k, k + 1 : seq_len - n_q + k + 1] for k in range(n_q)], dim=1) | |