Skip to content

Commit 7032852

Browse files
authored
remove scale to interval from #319 (#360)
1 parent 38f1e87 commit 7032852

File tree

2 files changed

+0
-34
lines changed

2 files changed

+0
-34
lines changed

test/test_functional.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,6 @@ def test_gain(self):
379379

380380
self.assertTrue(torch.allclose(waveform_gain, sox_gain_waveform, atol=1e-04))
381381

382-
def test_scale_to_interval(self):
383-
scaled = 5.5 # [-5.5, 5.5]
384-
waveform_scaled = F._scale_to_interval(self.waveform_train, scaled)
385-
386-
self.assertTrue(torch.max(waveform_scaled) <= scaled)
387-
self.assertTrue(torch.min(waveform_scaled) >= -scaled)
388-
389382
def test_dither(self):
390383
waveform_dithered = F.dither(self.waveform_train)
391384
waveform_dithered_noiseshaped = F.dither(self.waveform_train, noise_shaping=True)
@@ -582,12 +575,6 @@ def test_torchscript_gain(self):
582575

583576
_test_torchscript_functional(F.gain, tensor, gainDB)
584577

585-
def test_torchscript_scale_to_interval(self):
586-
tensor = torch.rand((1, 1000))
587-
scaled = 3.5
588-
589-
_test_torchscript_functional(F._scale_to_interval, tensor, scaled)
590-
591578
def test_torchscript_dither(self):
592579
tensor = torch.rand((1, 1000))
593580

torchaudio/functional.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -877,27 +877,6 @@ def gain(waveform, gain_db=1.0):
877877
return waveform * ratio
878878

879879

880-
def _scale_to_interval(waveform, interval_max=1.0):
881-
# type: (Tensor, float) -> Tensor
882-
r"""Scale the waveform to the interval [-interval_max, interval_max] across all dimensions.
883-
884-
Args:
885-
waveform (torch.Tensor): Tensor of audio of dimension (channel, time).
886-
interval_max (float): The bounds of the interval, where the float indicates
887-
the upper bound and the negative of the float indicates the lower
888-
bound (Default: `1.0`).
889-
Example: interval=1.0 -> [-1.0, 1.0]
890-
891-
Returns:
892-
torch.Tensor: the whole waveform scaled to interval.
893-
"""
894-
abs_max = torch.max(torch.abs(waveform))
895-
ratio = abs_max / interval_max
896-
waveform /= ratio
897-
898-
return waveform
899-
900-
901880
def _add_noise_shaping(dithered_waveform, waveform):
902881
r"""Noise shaping is calculated by error:
903882
error[n] = dithered[n] - original[n]

0 commit comments

Comments
 (0)