From abee3ecdd42dd542040e394a408bf25dd0e2fc1f Mon Sep 17 00:00:00 2001 From: iclementine Date: Thu, 19 Nov 2020 20:31:21 +0800 Subject: [PATCH] move datasets into parakeet.datasets --- parakeet/data/datasets.py | 44 --------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 parakeet/data/datasets.py diff --git a/parakeet/data/datasets.py b/parakeet/data/datasets.py deleted file mode 100644 index 35e18ab..0000000 --- a/parakeet/data/datasets.py +++ /dev/null @@ -1,44 +0,0 @@ -from paddle.io import Dataset -from os import listdir -from os.path import splitext, join -from pathlib import Path -import librosa - -class AudioFolderDataset(Dataset): - def __init__(self, path, sample_rate, extension="wav"): - self.root = path - self.sample_rate = sample_rate - self.extension = extension - self.file_names = [join(self.root, x) for x in listdir(self.root) \ - if splitext(x)[-1] == self.extension] - self.length = len(self.file_names) - - def __len__(self): - return self.length - - def __getitem__(self, i): - file_name = self.file_names[i] - y, sr = librosa.load(file_name, sr=self.sample_rate) # pylint: disable=unused-variable - return y - - -class LJSpeechMetaData(Dataset): - def __init__(self, root): - self.root = Path(root).expanduser() - wav_dir = self.root / "wavs" - csv_path = self.root / "metadata.csv" - records = [] - speaker_name = "ljspeech" - with open(str(csv_path), 'rt') as f: - for line in f: - filename, _, normalized_text = line.strip().split("|") - filename = str(wav_dir / (filename + ".wav")) - records.append([filename, normalized_text, speaker_name]) - self.records = records - - def __getitem__(self, i): - return self.records[i] - - def __len__(self): - return len(self.records) -