Skip to content

Commit

Permalink
fix test error and remove assets libritts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji Chen committed Jul 17, 2020
1 parent 1fec127 commit 77a7b6f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.

This file was deleted.

This file was deleted.

Binary file not shown.
3 changes: 1 addition & 2 deletions test/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def setUpClass(cls):
for label in cls.labels:
filename = f'{"_".join(str(l) for l in label)}.wav'
path = os.path.join(base_dir, filename)

data = get_whitenoise(sample_rate=8000, duration=6, n_channels=1, dtype='int16')
save_wav(path, data, 8000)
cls.data.append(normalize_wav(data))
Expand Down Expand Up @@ -153,7 +152,7 @@ def setUpClass(cls):
def test_libritts(self):
dataset = LIBRITTS(self.root_dir)
samples = list(dataset)
samples.sort(key=lambda s: s[2])
samples.sort(key=lambda s: s[4])

for i, (waveform,
sample_rate,
Expand Down
55 changes: 29 additions & 26 deletions torchaudio/datasets/libritts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,23 @@
URL = "train-clean-100"
FOLDER_IN_ARCHIVE = "LibriTTS"
_CHECKSUMS = {
"http://www.openslr.org/60/dev-clean.tar.gz":
"0c3076c1e5245bb3f0af7d82087ee207",
"http://www.openslr.org/60/dev-other.tar.gz":
"815555d8d75995782ac3ccd7f047213d",
"http://www.openslr.org/60/test-clean.tar.gz":
"7bed3bdb047c4c197f1ad3bc412db59f",
"http://www.openslr.org/60/test-other.tar.gz":
"ae3258249472a13b5abef2a816f733e4",
"http://www.openslr.org/60/train-clean-100.tar.gz":
"4a8c202b78fe1bc0c47916a98f3a2ea8",
"http://www.openslr.org/60/train-clean-360.tar.gz":
"a84ef10ddade5fd25df69596a2767b2d",
"http://www.openslr.org/60/train-other-500.tar.gz":
"7b181dd5ace343a5f38427999684aa6f",
"http://www.openslr.org/60/dev-clean.tar.gz": "0c3076c1e5245bb3f0af7d82087ee207",
"http://www.openslr.org/60/dev-other.tar.gz": "815555d8d75995782ac3ccd7f047213d",
"http://www.openslr.org/60/test-clean.tar.gz": "7bed3bdb047c4c197f1ad3bc412db59f",
"http://www.openslr.org/60/test-other.tar.gz": "ae3258249472a13b5abef2a816f733e4",
"http://www.openslr.org/60/train-clean-100.tar.gz": "4a8c202b78fe1bc0c47916a98f3a2ea8",
"http://www.openslr.org/60/train-clean-360.tar.gz": "a84ef10ddade5fd25df69596a2767b2d",
"http://www.openslr.org/60/train-other-500.tar.gz": "7b181dd5ace343a5f38427999684aa6f",
}


def load_libritts_item(fileid: str,
path: str,
ext_audio: str,
ext_original_txt: str,
ext_normalized_txt: str) -> Tuple[Tensor, int, str, str, int, int, str]:
def load_libritts_item(
fileid: str,
path: str,
ext_audio: str,
ext_original_txt: str,
ext_normalized_txt: str,
) -> Tuple[Tensor, int, str, str, int, int, str]:
speaker_id, chapter_id, segment_id, utterance_id = fileid.split("_")
utterance_id = fileid

Expand All @@ -55,7 +50,7 @@ def load_libritts_item(fileid: str,
original_utterance = ft.readline()

# Load normalized text
with open(normalized_text, 'r') as ft:
with open(normalized_text, "r") as ft:
normalized_utterance = ft.readline()

return (
Expand All @@ -79,11 +74,13 @@ class LIBRITTS(Dataset):
_ext_normalized_txt = ".normalized.txt"
_ext_audio = ".wav"

def __init__(self,
root: str,
url: str = URL,
folder_in_archive: str = FOLDER_IN_ARCHIVE,
download: bool = False) -> None:
def __init__(
self,
root: str,
url: str = URL,
folder_in_archive: str = FOLDER_IN_ARCHIVE,
download: bool = False,
) -> None:

if url in [
"dev-clean",
Expand Down Expand Up @@ -122,7 +119,13 @@ def __init__(self,

def __getitem__(self, n: int) -> Tuple[Tensor, int, str, str, int, int, str]:
fileid = self._walker[n]
return load_libritts_item(fileid, self._path, self._ext_audio, self._ext_original_txt, self._ext_normalized_txt)
return load_libritts_item(
fileid,
self._path,
self._ext_audio,
self._ext_original_txt,
self._ext_normalized_txt,
)

def __len__(self) -> int:
return len(self._walker)

0 comments on commit 77a7b6f

Please sign in to comment.