"src/vscode:/vscode.git/clone" did not exist on "f6fb3282b18f44f14bcb95a34a16203906df992a"
Unverified Commit 436470c2 authored by Isaac Seessel's avatar Isaac Seessel Committed by GitHub
Browse files

Remove deprecated load_wav functions (#1362)

parent 9395ad64
...@@ -6,7 +6,7 @@ torchaudio.backend ...@@ -6,7 +6,7 @@ torchaudio.backend
Overview Overview
~~~~~~~~ ~~~~~~~~
:mod:`torchaudio.backend` module provides implementations for audio file I/O functionalities, which are ``torchaudio.info``, ``torchaudio.load``, ``torchaudio.load_wav`` and ``torchaudio.save``. :mod:`torchaudio.backend` module provides implementations for audio file I/O functionalities, which are ``torchaudio.info``, ``torchaudio.load``, and ``torchaudio.save``.
There are currently four implementations available. There are currently four implementations available.
...@@ -14,7 +14,7 @@ There are currently four implementations available. ...@@ -14,7 +14,7 @@ There are currently four implementations available.
* :ref:`"soundfile" <soundfile_backend>` (default on Windows) * :ref:`"soundfile" <soundfile_backend>` (default on Windows)
.. note:: .. note::
Instead of calling functions in ``torchaudio.backend`` directly, please use ``torchaudio.info``, ``torchaudio.load``, ``torchaudio.load_wav`` and ``torchaudio.save`` with proper backend set with :func:`torchaudio.set_audio_backend`. Instead of calling functions in ``torchaudio.backend`` directly, please use ``torchaudio.info``, ``torchaudio.load``, and ``torchaudio.save`` with proper backend set with :func:`torchaudio.set_audio_backend`.
Availability Availability
------------ ------------
...@@ -58,9 +58,6 @@ load ...@@ -58,9 +58,6 @@ load
.. autofunction:: torchaudio.backend.sox_io_backend.load .. autofunction:: torchaudio.backend.sox_io_backend.load
.. autofunction:: torchaudio.backend.sox_io_backend.load_wav
save save
---- ----
...@@ -89,9 +86,6 @@ load ...@@ -89,9 +86,6 @@ load
.. autofunction:: torchaudio.backend.soundfile_backend.load .. autofunction:: torchaudio.backend.soundfile_backend.load
.. autofunction:: torchaudio.backend.soundfile_backend.load_wav
save save
---- ----
......
...@@ -16,10 +16,6 @@ Refer to :ref:`backend` for the detail. ...@@ -16,10 +16,6 @@ Refer to :ref:`backend` for the detail.
Load audio file into torch.Tensor object. Refer to :ref:`backend` for the detail. Load audio file into torch.Tensor object. Refer to :ref:`backend` for the detail.
.. function:: torchaudio.load_wav(filepath: str, ...)
Load audio file into torch.Tensor, Refer to :ref:`backend` for the detail.
.. function:: torchaudio.save(filepath: str, src: torch.Tensor, sample_rate: int, ...) .. function:: torchaudio.save(filepath: str, src: torch.Tensor, sample_rate: int, ...)
Save torch.Tensor object into an audio format. Refer to :ref:`backend` for the detail. Save torch.Tensor object into an audio format. Refer to :ref:`backend` for the detail.
......
...@@ -15,7 +15,6 @@ class BackendSwitchMixin: ...@@ -15,7 +15,6 @@ class BackendSwitchMixin:
else: else:
assert torchaudio.get_audio_backend() == self.backend assert torchaudio.get_audio_backend() == self.backend
assert torchaudio.load == self.backend_module.load assert torchaudio.load == self.backend_module.load
assert torchaudio.load_wav == self.backend_module.load_wav
assert torchaudio.save == self.backend_module.save assert torchaudio.save == self.backend_module.save
assert torchaudio.info == self.backend_module.info assert torchaudio.info == self.backend_module.info
......
...@@ -6,6 +6,7 @@ import subprocess ...@@ -6,6 +6,7 @@ import subprocess
import torch import torch
import torchaudio import torchaudio
import utils import utils
from torchaudio_unittest import common_utils
def run(exe_path, scp_path, out_dir, wave_len, num_outputs, remove_files, log_level): def run(exe_path, scp_path, out_dir, wave_len, num_outputs, remove_files, log_level):
...@@ -102,7 +103,7 @@ def decode(fn, sound_path, exe_path, scp_path, out_dir): ...@@ -102,7 +103,7 @@ def decode(fn, sound_path, exe_path, scp_path, out_dir):
# print args for python # print args for python
inputs['dither'] = 0.0 inputs['dither'] = 0.0
logging.info(inputs) logging.info(inputs)
sound, sample_rate = torchaudio.load_wav(sound_path) sound, sample_rate = common_utils.load_wav(sound_path, normalize=False)
kaldi_output_dict = {k: v for k, v in torchaudio.kaldi_io.read_mat_ark(out_fn)} kaldi_output_dict = {k: v for k, v in torchaudio.kaldi_io.read_mat_ark(out_fn)}
res = torchaudio.compliance.kaldi.fbank(sound, **inputs) res = torchaudio.compliance.kaldi.fbank(sound, **inputs)
torch.set_printoptions(precision=10, sci_mode=False) torch.set_printoptions(precision=10, sci_mode=False)
......
...@@ -144,7 +144,7 @@ class Test_Kaldi(common_utils.TempDirMixin, common_utils.TorchaudioTestCase): ...@@ -144,7 +144,7 @@ class Test_Kaldi(common_utils.TempDirMixin, common_utils.TorchaudioTestCase):
atol (float): absolute tolerance atol (float): absolute tolerance
rtol (float): relative tolerance rtol (float): relative tolerance
""" """
sound, sr = torchaudio.load_wav(sound_filepath) sound, sr = common_utils.load_wav(sound_filepath, normalize=False)
files = self.test_filepaths[filepath_key] files = self.test_filepaths[filepath_key]
assert len(files) == expected_num_files, \ assert len(files) == expected_num_files, \
......
from pathlib import Path from pathlib import Path
from typing import Any, Callable, Optional, Tuple, Union from typing import Callable, Optional, Tuple, Union
from torch import Tensor from torch import Tensor
...@@ -14,10 +14,6 @@ def load(filepath: Union[str, Path], ...@@ -14,10 +14,6 @@ def load(filepath: Union[str, Path],
raise RuntimeError('No audio I/O backend is available.') raise RuntimeError('No audio I/O backend is available.')
def load_wav(filepath: Union[str, Path], **kwargs: Any) -> Tuple[Tensor, int]:
raise RuntimeError('No audio I/O backend is available.')
def save(filepath: str, src: Tensor, sample_rate: int, precision: int = 16, channels_first: bool = True) -> None: def save(filepath: str, src: Tensor, sample_rate: int, precision: int = 16, channels_first: bool = True) -> None:
raise RuntimeError('No audio I/O backend is available.') raise RuntimeError('No audio I/O backend is available.')
......
...@@ -424,26 +424,3 @@ def save( ...@@ -424,26 +424,3 @@ def save(
soundfile.write( soundfile.write(
file=filepath, data=src, samplerate=sample_rate, subtype=subtype, format=format file=filepath, data=src, samplerate=sample_rate, subtype=subtype, format=format
) )
@_mod_utils.requires_module("soundfile")
@_mod_utils.deprecated('Please use "torchaudio.load".', "0.9.0")
def load_wav(
filepath: str,
frame_offset: int = 0,
num_frames: int = -1,
channels_first: bool = True,
) -> Tuple[torch.Tensor, int]:
"""Load wave file.
This function is defined only for the purpose of compatibility against other backend
for simple usecases, such as ``torchaudio.load_wav(filepath)``.
The implementation is same as :py:func:`load`.
"""
return load(
filepath,
frame_offset,
num_frames,
normalize=False,
channels_first=channels_first,
)
...@@ -313,20 +313,3 @@ def save( ...@@ -313,20 +313,3 @@ def save(
filepath = os.fspath(filepath) filepath = os.fspath(filepath)
torch.ops.torchaudio.sox_io_save_audio_file( torch.ops.torchaudio.sox_io_save_audio_file(
filepath, src, sample_rate, channels_first, compression, format, encoding, bits_per_sample) filepath, src, sample_rate, channels_first, compression, format, encoding, bits_per_sample)
@_mod_utils.requires_sox()
@_mod_utils.deprecated('Please use "torchaudio.load".', '0.9.0')
def load_wav(
filepath: str,
frame_offset: int = 0,
num_frames: int = -1,
channels_first: bool = True,
) -> Tuple[torch.Tensor, int]:
"""Load wave file.
This function is defined only for the purpose of compatibility against other backend
for simple usecases, such as ``torchaudio.load_wav(filepath)``.
The implementation is same as :py:func:`load`.
"""
return load(filepath, frame_offset, num_frames, normalize=False, channels_first=channels_first)
...@@ -53,7 +53,7 @@ def set_audio_backend(backend: Optional[str]): ...@@ -53,7 +53,7 @@ def set_audio_backend(backend: Optional[str]):
else: else:
raise NotImplementedError(f'Unexpected backend "{backend}"') raise NotImplementedError(f'Unexpected backend "{backend}"')
for func in ['save', 'load', 'load_wav', 'info']: for func in ['save', 'load', 'info']:
setattr(torchaudio, func, getattr(module, func)) setattr(torchaudio, func, getattr(module, func))
......
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