Skip to content

Commit 0e11c80

Browse files
authored
Merge pull request #341 from iver56/ij/flatten-ravel
Make Mp3Compression slightly faster by replacing flatten with ravel
2 parents 5bc2bb8 + 064411a commit 0e11c80

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

audiomentations/augmentations/mp3_compression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def apply_lameenc(self, samples: NDArray[np.float32], sample_rate: int):
188188

189189
if num_channels == 1:
190190
if int_samples.ndim == 1 and degraded_samples.ndim == 2:
191-
degraded_samples = degraded_samples.flatten()
191+
degraded_samples = np.ravel(degraded_samples)
192192
elif int_samples.ndim == 2 and degraded_samples.ndim == 1:
193193
degraded_samples = degraded_samples.reshape((1, -1))
194194

@@ -239,7 +239,7 @@ def apply_pydub(self, samples: NDArray[np.float32], sample_rate: int):
239239

240240
if num_channels == 1:
241241
if int_samples.ndim == 1 and degraded_samples.ndim == 2:
242-
degraded_samples = degraded_samples.flatten()
242+
degraded_samples = np.ravel(degraded_samples)
243243
elif int_samples.ndim == 2 and degraded_samples.ndim == 1:
244244
degraded_samples = degraded_samples.reshape((1, -1))
245245

0 commit comments

Comments
 (0)