Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kuacakuaca committed Nov 28, 2023
1 parent f1f8081 commit 7bd8e6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions i6_models/primitives/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def forward(self, raw_audio, length) -> Tuple[torch.Tensor, torch.Tensor]:
power_spectrum = torch.abs(torch.fft.rfftn(smoothed, s=self.n_fft)) ** 2 # [B, T', F=n_fft//2+1]
power_spectrum = power_spectrum.transpose(1, 2) # [B, F, T']
else:
raise ValueError("Invalid spectrum type.")
raise ValueError(f"Invalid spectrum type {self.spectrum_type!r}.")

if len(power_spectrum.size()) == 2:
# For some reason torch.stft removes the batch axis for batch sizes of 1, so we need to add it again
Expand All @@ -145,5 +145,5 @@ def forward(self, raw_audio, length) -> Tuple[torch.Tensor, torch.Tensor]:
elif self.spectrum_type == SpectrumType.RFFTN:
length = ((length - self.win_length) // self.hop_length) + 1
else:
raise ValueError("Invalid spectrum type.")
raise ValueError(f"Invalid spectrum type {self.spectrum_type!r}.")
return feature_data, length.int()

0 comments on commit 7bd8e6c

Please sign in to comment.