Skip to content

Commit a4512ff

Browse files
Remove the apply_codec function (#4082)
1 parent a059947 commit a4512ff

File tree

4 files changed

+0
-83
lines changed

4 files changed

+0
-83
lines changed

docs/source/functional.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Utility
2323
mask_along_axis_iid
2424
mu_law_encoding
2525
mu_law_decoding
26-
apply_codec
2726
resample
2827
loudness
2928
convolve

src/torchaudio/functional/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
add_noise,
3333
amplitude_to_DB,
3434
apply_beamforming,
35-
apply_codec,
3635
compute_deltas,
3736
convolve,
3837
create_dct,
@@ -111,7 +110,6 @@
111110
"riaa_biquad",
112111
"treble_biquad",
113112
"vad",
114-
"apply_codec",
115113
"resample",
116114
"edit_distance",
117115
"pitch_shift",

src/torchaudio/functional/functional.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"mask_along_axis_iid",
3535
"sliding_window_cmn",
3636
"spectral_centroid",
37-
"apply_codec",
3837
"resample",
3938
"edit_distance",
4039
"loudness",
@@ -1301,51 +1300,6 @@ def spectral_centroid(
13011300
return (freqs * specgram).sum(dim=freq_dim) / specgram.sum(dim=freq_dim)
13021301

13031302

1304-
@deprecated("Please migrate to :py:class:`torchaudio.io.AudioEffector`.", remove=False)
1305-
def apply_codec(
1306-
waveform: Tensor,
1307-
sample_rate: int,
1308-
format: str,
1309-
channels_first: bool = True,
1310-
compression: Optional[float] = None,
1311-
encoding: Optional[str] = None,
1312-
bits_per_sample: Optional[int] = None,
1313-
) -> Tensor:
1314-
r"""
1315-
Apply codecs as a form of augmentation.
1316-
1317-
.. devices:: CPU
1318-
1319-
Args:
1320-
waveform (Tensor): Audio data. Must be 2 dimensional. See also ```channels_first```.
1321-
sample_rate (int): Sample rate of the audio waveform.
1322-
format (str): File format.
1323-
channels_first (bool, optional):
1324-
When True, both the input and output Tensor have dimension `(channel, time)`.
1325-
Otherwise, they have dimension `(time, channel)`.
1326-
compression (float or None, optional): Used for formats other than WAV.
1327-
For more details see :py:func:`torchaudio.backend.sox_io_backend.save`.
1328-
encoding (str or None, optional): Changes the encoding for the supported formats.
1329-
For more details see :py:func:`torchaudio.backend.sox_io_backend.save`.
1330-
bits_per_sample (int or None, optional): Changes the bit depth for the supported formats.
1331-
For more details see :py:func:`torchaudio.backend.sox_io_backend.save`.
1332-
1333-
Returns:
1334-
Tensor: Resulting Tensor.
1335-
If ``channels_first=True``, it has `(channel, time)` else `(time, channel)`.
1336-
"""
1337-
from torchaudio.backend import _sox_io_backend
1338-
1339-
with tempfile.NamedTemporaryFile() as f:
1340-
torchaudio.backend._sox_io_backend.save(
1341-
f.name, waveform, sample_rate, channels_first, compression, format, encoding, bits_per_sample
1342-
)
1343-
augmented, sr = _sox_io_backend.load(f.name, channels_first=channels_first, format=format)
1344-
if sr != sample_rate:
1345-
augmented = resample(augmented, sr, sample_rate)
1346-
return augmented
1347-
1348-
13491303
_CPU = torch.device("cpu")
13501304

13511305

test/torchaudio_unittest/functional/functional_cpu_test.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,3 @@ def test_lfilter_9th_order_filter_stability(self):
2121
class TestFunctionalFloat64(Functional, PytorchTestCase):
2222
dtype = torch.float64
2323
device = torch.device("cpu")
24-
25-
26-
@unittest.skip("deprecated")
27-
class TestApplyCodec(TorchaudioTestCase):
28-
def _smoke_test(self, format, compression, check_num_frames):
29-
"""
30-
The purpose of this test suite is to verify that apply_codec functionalities do not exhibit
31-
abnormal behaviors.
32-
"""
33-
sample_rate = 8000
34-
num_frames = 3 * sample_rate
35-
num_channels = 2
36-
waveform = torch.rand(num_channels, num_frames)
37-
38-
augmented = F.apply_codec(waveform, sample_rate, format, True, compression)
39-
assert augmented.dtype == waveform.dtype
40-
assert augmented.shape[0] == num_channels
41-
if check_num_frames:
42-
assert augmented.shape[1] == num_frames
43-
44-
def test_wave(self):
45-
self._smoke_test("wav", compression=None, check_num_frames=True)
46-
47-
@parameterized.expand([(96,), (128,), (160,), (192,), (224,), (256,), (320,)])
48-
def test_mp3(self, compression):
49-
self._smoke_test("mp3", compression, check_num_frames=False)
50-
51-
@parameterized.expand([(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,)])
52-
def test_flac(self, compression):
53-
self._smoke_test("flac", compression, check_num_frames=False)
54-
55-
@parameterized.expand([(-1,), (0,), (1,), (2,), (3,), (3.6,), (5,), (10,)])
56-
def test_vorbis(self, compression):
57-
self._smoke_test("vorbis", compression, check_num_frames=False)

0 commit comments

Comments
 (0)