Skip to content

Commit 331ab90

Browse files
committed
Warn if the input dtype to TimeStretch is not complex
1 parent 172260f commit 331ab90

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/torchaudio/transforms/_transforms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,9 @@ def forward(self, complex_specgrams: Tensor, overriding_rate: Optional[float] =
10661066
Stretched spectrogram. The resulting tensor is of the corresponding complex dtype
10671067
as the input spectrogram, and the number of frames is changed to ``ceil(num_frame / rate)``.
10681068
"""
1069+
if not torch.is_complex(complex_specgrams):
1070+
warnings.warn("The input spectrogram must be complex type.", stacklevel=2)
1071+
10691072
if overriding_rate is None:
10701073
if self.fixed_rate is None:
10711074
raise ValueError("If no fixed_rate is specified, must pass a valid rate to the forward method.")

0 commit comments

Comments
 (0)