When creating a custom dataset loader like that shown here. Is it advisable to do something like
class CustomDataset(Dataset):
def __init__(self, csv_file, root_dir):
self.annotations = pd.read_csv(csv_file)
self.root_dir = root_dir
def __len__(self):
return len(self.annotations)
def __getitem__(self, index):
audio_path = os.path.join(self.root_dir, self.annotations.iloc[index, 0])
target_path = os.path.join(self.root_dir, self.annotations.iloc[index, 1])
audio, _ = torchaudio.load(audio_path)
target, _ = torchaudio.load(target_path)
return audio, target
when both the input and expected output are waveforms? In my case, I created a csv file that contains the filenames of both audios and I just load the path-like object into torchaudio.load()
. Also, how do I ensure that all the audio
and target
in a batch are of the same length when being loaded?