| | |
| | | """ |
| | | if torch.is_tensor(array): |
| | | if array.shape[axis] > length: |
| | | array = array.index_select( |
| | | dim=axis, index=torch.arange(length, device=array.device) |
| | | ) |
| | | array = array.index_select(dim=axis, index=torch.arange(length, device=array.device)) |
| | | |
| | | if array.shape[axis] < length: |
| | | pad_widths = [(0, 0)] * array.ndim |
| | |
| | | |
| | | |
| | | @lru_cache(maxsize=None) |
| | | def mel_filters(device, n_mels: int, filters_path: str=None) -> torch.Tensor: |
| | | def mel_filters(device, n_mels: int, filters_path: str = None) -> torch.Tensor: |
| | | """ |
| | | load the mel filterbank matrix for projecting STFT into a Mel spectrogram. |
| | | Allows decoupling librosa dependency; saved using: |