Skip to content

Commit

Permalink
Fix a bug where SomeOf didn't treat spectrogram transforms properly
Browse files Browse the repository at this point in the history
  • Loading branch information
iver56 committed Nov 18, 2021
1 parent ae4b137 commit 8306f74
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions audiomentations/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def randomize_parameters(self, *args, **kwargs):
)
else:
num_transforms_to_apply = self.num_transforms
all_transforms_indexes = list(np.arange(len(self.transforms)))
all_transforms_indexes = list(range(len(self.transforms)))
self.transform_indexes = sorted(
random.sample(all_transforms_indexes, num_transforms_to_apply)
)
Expand All @@ -191,9 +191,9 @@ def __call__(self, *args, **kwargs):
magnitude_spectrogram = args[0]

for transform_index in self.transform_indexes:
magnitude_spectrogram = self.transforms[
self.transform_indexes[transform_index]
](magnitude_spectrogram)
magnitude_spectrogram = self.transforms[transform_index](
magnitude_spectrogram
)

return magnitude_spectrogram
else: # The transforms are subclasses of BaseWaveformTransform
Expand All @@ -205,9 +205,7 @@ def __call__(self, *args, **kwargs):
sample_rate = args[1]

for transform_index in self.transform_indexes:
samples = self.transforms[transform_index](
samples, sample_rate
)
samples = self.transforms[transform_index](samples, sample_rate)

return samples

Expand Down

0 comments on commit 8306f74

Please sign in to comment.