bug in metric calculation

This commit is contained in:
Steffen Illium
2021-03-27 16:39:07 +01:00
parent 6816e423ff
commit 1d1b154460
5 changed files with 38 additions and 15 deletions

View File

@@ -88,10 +88,7 @@ class LibrosaAudioToMel(object):
def __init__(self, amplitude_to_db=False, power_to_db=False, **mel_kwargs):
assert not all([amplitude_to_db, power_to_db]), "Choose amplitude_to_db or power_to_db, not both!"
# Mel kwargs are:
# sr
# n_mels
# n_fft
# hop_length
# sr n_mels n_fft hop_length
self.mel_kwargs = mel_kwargs
self.amplitude_to_db = amplitude_to_db

View File

@@ -34,10 +34,10 @@ class LibrosaAudioToMelDataset(Dataset):
self.audio_path = Path(audio_file_path)
mel_folder_suffix = self.audio_path.parent.parent.name
self.mel_folder = Path(str(self.audio_path)
.replace(mel_folder_suffix, f'{mel_folder_suffix}_mel_folder')).parent.parent
self.mel_file_path = Path(str(self.audio_path)
.replace(mel_folder_suffix, f'{mel_folder_suffix}_mel_folder')
.replace(self.audio_path.suffix, '.npy'))
self.mel_file_path = self.mel_folder / f'{self.audio_path.stem}.npy'
self.audio_augmentations = audio_augmentations
@@ -45,7 +45,7 @@ class LibrosaAudioToMelDataset(Dataset):
self.audio_file_duration, mel_kwargs['sr'], mel_kwargs['hop_length'],
mel_kwargs['n_mels'], transform=mel_augmentations)
self._mel_transform = Compose([LibrosaAudioToMel(**mel_kwargs),
self._mel_transform = Compose([LibrosaAudioToMel(power_to_db=False, **mel_kwargs),
MelToImage()
])

View File

@@ -64,9 +64,9 @@ class ShiftTime(_BaseTransformation):
# Set to silence for heading/ tailing
shift = int(shift)
if shift > 0:
augmented_data[:shift, :] = 0
augmented_data[:, :shift] = 0
else:
augmented_data[shift:, :] = 0
augmented_data[:, shift:] = 0
return augmented_data
else:
return x