Repository: pytorch/audio

Issue:
Adding LJ Speech dataset
## 🚀 Feature
Adding publicly available [LJ Speech](https://keithito.com/LJ-Speech-Dataset/) dataset, widely used for TTS tasks.

## Motivation

It will be convenient for researchers in speech synthesis (and speech processing in general) to get directly to model development and spend less time on building custom pipelines for loading datasets. Also LJ Speech is considered as a benchmark dataset and many papers in speech synthesis report their performance scores based on it.

## Additional context

I'd like to contribute by adding LJ Speech dataset to torchaudio. What repository owners thing of having it in the library?


Discussion:
Yes, we would welcome this dataset. In general, we try to keep the available datasets to the most popular and requested. 

Please keep in mind that we keep the structure of the code very close to the ones currently available, see for instance [librispeech](https://github.com/pytorch/audio/blob/master/torchaudio/datasets/librispeech.py).

Resolving patch:
diff --git a/torchaudio/datasets/__init__.py b/torchaudio/datasets/__init__.py
--- a/torchaudio/datasets/__init__.py
+++ b/torchaudio/datasets/__init__.py
@@ -3,12 +3,14 @@
 from .utils import bg_iterator, diskcache_iterator
 from .vctk import VCTK
 from .yesno import YESNO
+from .ljspeech import LJSPEECH
 
 __all__ = (
     "COMMONVOICE",
     "LIBRISPEECH",
     "VCTK",
     "YESNO",
+    "LJSPEECH",
     "diskcache_iterator",
     "bg_iterator",
 )
diff --git a/torchaudio/datasets/ljspeech.py b/torchaudio/datasets/ljspeech.py
new file mode 100644
--- /dev/null
+++ b/torchaudio/datasets/ljspeech.py
@@ -0,0 +1,66 @@
+import os
+import csv
+
+import torchaudio
+from torchaudio.datasets.utils import download_url, extract_archive, unicode_csv_reader
+from torch.utils.data import Dataset
+
+URL = "https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2"
+FOLDER_IN_ARCHIVE = "wavs"
+
+
+def load_ljspeech_item(line, path, ext_audio):
+    assert len(line) == 3
+    fileid, transcript, normalized_transcript = line
+    fileid_audio = fileid + ext_audio
+    fileid_audio = os.path.join(path, fileid_audio)
+
+    # Load audio
+    waveform, sample_rate = torchaudio.load(fileid_audio)
+
+    return (
+        waveform,
+        sample_rate,
+        transcript,
+        normalized_transcript,
+    )
+
+
+class LJSPEECH(Dataset):
+    """
+    Create a Dataset for LJSpeech-1.1. Each item is a tuple of the form:
+    waveform, sample_rate, transcript, normalized_transcript
+    """
+
+    _ext_audio = ".wav"
+    _ext_archive = '.tar.bz2'
+
+    def __init__(
+            self, root, url=URL, folder_in_archive=FOLDER_IN_ARCHIVE, download=False
+    ):
+
+        basename = os.path.basename(url)
+        archive = os.path.join(root, basename)
+
+        basename = basename.split(self._ext_archive)[0]
+        folder_in_archive = os.path.join(basename, folder_in_archive)
+
+        self._path = os.path.join(root, folder_in_archive)
+        self._metadata_path = os.path.join(root, basename, 'metadata.csv')
+
+        if download:
+            if not os.path.isdir(self._path):
+                if not os.path.isfile(archive):
+                    download_url(url, root)
+                extract_archive(archive)
+
+        with open(self._metadata_path, "r") as metadata:
+            walker = unicode_csv_reader(metadata, delimiter="|", quoting=csv.QUOTE_NONE)
+            self._walker = list(walker)
+
+    def __getitem__(self, n):
+        line = self._walker[n]
+        return load_ljspeech_item(line, self._path, self._ext_audio)
+
+    def __len__(self):
+        return len(self._walker)


Test patch:
diff --git a/test/assets/LJSpeech-1.1/metadata.csv b/test/assets/LJSpeech-1.1/metadata.csv
new file mode 100644
--- /dev/null
+++ b/test/assets/LJSpeech-1.1/metadata.csv
@@ -0,0 +1 @@
+LJ001-0001|Printing, in the only sense with which we are at present concerned, differs from most if not from all the arts and crafts represented in the Exhibition|Printing, in the only sense with which we are at present concerned, differs from most if not from all the arts and crafts represented in the Exhibition
diff --git a/test/assets/LJSpeech-1.1/wavs/LJ001-0001.wav b/test/assets/LJSpeech-1.1/wavs/LJ001-0001.wav
new file mode 100644
Binary files /dev/null and b/test/assets/LJSpeech-1.1/wavs/LJ001-0001.wav differ
diff --git a/test/test_datasets.py b/test/test_datasets.py
--- a/test/test_datasets.py
+++ b/test/test_datasets.py
@@ -6,6 +6,7 @@
 from torchaudio.datasets.utils import diskcache_iterator, bg_iterator
 from torchaudio.datasets.vctk import VCTK
 from torchaudio.datasets.yesno import YESNO
+from torchaudio.datasets.ljspeech import LJSPEECH
 
 import common_utils
 
@@ -47,6 +48,10 @@ def test_commonvoice_bg(self):
         for d in data:
             pass
 
+    def test_ljspeech(self):
+        data = LJSPEECH(self.path)
+        data[0]
+
 
 if __name__ == "__main__":
     unittest.main()