Commit 11328d23 authored by Caroline Chen's avatar Caroline Chen Committed by Facebook GitHub Bot
Browse files

Raise error for resampling int waveform (#2318)

Summary:
Resolves https://github.com/pytorch/audio/issues/2294

Raise an error if the waveform to be resampled is not of floating point type. The `conv1d` operation used in resampling and `nn.Module` used for the transforms don't support integer type.

Pull Request resolved: https://github.com/pytorch/audio/pull/2318

Reviewed By: mthrok

Differential Revision: D35379276

Pulled By: carolineechen

fbshipit-source-id: f8f9539a051e7c3d22bcb45ca6a34aaef67abed0
parent 66185e00
...@@ -1399,6 +1399,9 @@ def _apply_sinc_resample_kernel( ...@@ -1399,6 +1399,9 @@ def _apply_sinc_resample_kernel(
kernel: Tensor, kernel: Tensor,
width: int, width: int,
): ):
if not waveform.is_floating_point():
raise TypeError(f"Expected floating point type for waveform tensor, but received {waveform.dtype}.")
orig_freq = int(orig_freq) // gcd orig_freq = int(orig_freq) // gcd
new_freq = int(new_freq) // gcd new_freq = int(new_freq) // gcd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment