Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
58ef8fb6
"vscode:/vscode.git/clone" did not exist on "565f8d417ec8d210c277021752ebd72cd4f179f5"
Unverified
Commit
58ef8fb6
authored
Dec 23, 2020
by
Aziz
Committed by
GitHub
Dec 23, 2020
Browse files
Remove deprecated transform from Dataset (#1120)
parent
47c2040e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
51 deletions
+16
-51
torchaudio/datasets/vctk.py
torchaudio/datasets/vctk.py
+11
-28
torchaudio/datasets/yesno.py
torchaudio/datasets/yesno.py
+5
-23
No files found.
torchaudio/datasets/vctk.py
View file @
58ef8fb6
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
(
...
...
torchaudio/datasets/yesno.py
View file @
58ef8fb6
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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment