Unverified Commit 58ef8fb6 authored by Aziz's avatar Aziz Committed by GitHub
Browse files

Remove deprecated transform from Dataset (#1120)

parent 47c2040e
import os
import warnings
from typing import Any, Tuple, Union
from pathlib import Path
from typing import Tuple, Union
import torchaudio
from torch import Tensor
from torch.utils.data import Dataset
import torchaudio
from torchaudio.datasets.utils import (
download_url,
extract_archive,
......@@ -66,8 +67,6 @@ class VCTK(Dataset):
Giving ``download=True`` will result in error as the dataset is no longer
publicly available.
downsample (bool, optional): Not used.
transform (callable, optional): Optional transform applied on waveform. (default: ``None``)
target_transform (callable, optional): Optional transform applied on utterance. (default: ``None``)
"""
_folder_txt = "txt"
......@@ -81,9 +80,7 @@ class VCTK(Dataset):
url: str = URL,
folder_in_archive: str = FOLDER_IN_ARCHIVE,
download: bool = False,
downsample: bool = False,
transform: Any = None,
target_transform: Any = None) -> None:
downsample: bool = False) -> None:
if downsample:
warnings.warn(
......@@ -92,17 +89,7 @@ class VCTK(Dataset):
"and suppress this warning."
)
if transform is not None or target_transform is not None:
warnings.warn(
"In the next version, transforms will not be part of the dataset. "
"Please remove the option `transform=True` and "
"`target_transform=True` to suppress this warning."
)
self.downsample = downsample
self.transform = transform
self.target_transform = target_transform
# Get string representation of 'root' in case Path object is passed
root = os.fspath(root)
......@@ -149,10 +136,6 @@ class VCTK(Dataset):
# return item
waveform, sample_rate, utterance, speaker_id, utterance_id = item
if self.transform is not None:
waveform = self.transform(waveform)
if self.target_transform is not None:
utterance = self.target_transform(utterance)
return waveform, sample_rate, utterance, speaker_id, utterance_id
def __len__(self) -> int:
......@@ -182,12 +165,12 @@ class VCTK_092(Dataset):
"""
def __init__(
self,
root: str,
mic_id: str = "mic2",
download: bool = False,
url: str = URL,
audio_ext=".flac",
self,
root: str,
mic_id: str = "mic2",
download: bool = False,
url: str = URL,
audio_ext=".flac",
):
if mic_id not in ["mic1", "mic2"]:
raise RuntimeError(
......@@ -233,7 +216,7 @@ class VCTK_092(Dataset):
continue
utterance_dir = os.path.join(self._txt_dir, speaker_id)
for utterance_file in sorted(
f for f in os.listdir(utterance_dir) if f.endswith(".txt")
f for f in os.listdir(utterance_dir) if f.endswith(".txt")
):
utterance_id = os.path.splitext(utterance_file)[0]
audio_path_mic = os.path.join(
......
import os
import warnings
from typing import Any, List, Tuple, Union
from pathlib import Path
from typing import List, Tuple, Union
import torchaudio
from torch import Tensor
from torch.utils.data import Dataset
import torchaudio
from torchaudio.datasets.utils import (
download_url,
extract_archive,
......@@ -15,7 +15,7 @@ URL = "http://www.openslr.org/resources/1/waves_yesno.tar.gz"
FOLDER_IN_ARCHIVE = "waves_yesno"
_CHECKSUMS = {
"http://www.openslr.org/resources/1/waves_yesno.tar.gz":
"962ff6e904d2df1126132ecec6978786"
"962ff6e904d2df1126132ecec6978786"
}
......@@ -41,8 +41,6 @@ class YESNO(Dataset):
The top-level directory of the dataset. (default: ``"waves_yesno"``)
download (bool, optional):
Whether to download the dataset if it is not found at root path. (default: ``False``).
transform (callable, optional): Optional transform applied on waveform. (default: ``None``)
target_transform (callable, optional): Optional transform applied on utterance. (default: ``None``)
"""
_ext_audio = ".wav"
......@@ -51,19 +49,7 @@ class YESNO(Dataset):
root: Union[str, Path],
url: str = URL,
folder_in_archive: str = FOLDER_IN_ARCHIVE,
download: bool = False,
transform: Any = None,
target_transform: Any = None) -> None:
if transform is not None or target_transform is not None:
warnings.warn(
"In the next version, transforms will not be part of the dataset. "
"Please remove the option `transform=True` and "
"`target_transform=True` to suppress this warning."
)
self.transform = transform
self.target_transform = target_transform
download: bool = False) -> None:
# Get string representation of 'root' in case Path object is passed
root = os.fspath(root)
......@@ -102,10 +88,6 @@ class YESNO(Dataset):
# return item
waveform, sample_rate, labels = item
if self.transform is not None:
waveform = self.transform(waveform)
if self.target_transform is not None:
labels = self.target_transform(labels)
return waveform, sample_rate, labels
def __len__(self) -> int:
......
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