Closed btamm12 closed 1 year ago
Thanks for reporting this! That is indeed not ideal, so there's room for improvement
Until this gets fixed, please use pydub directly or make sure that your float values don't exceed [-1, 1], ref the bullet point in the known limitations section in the docs https://iver56.github.io/audiomentations/#known-limitations
A possible solution could be to have the Mp3Compression transform check the most extreme sample. If it exceeds 1, peak-normalize the audio before encoding to mp3, and then post-gain-compensate the decoded audio.
The fix for this is included in the v0.30.0 release
When audio segment's amplitude exceeds +/- 1, there are audible Mp3Compression artifacts. This is unexpected behavior because audiomentations uses pydub under the hood and when I run pydub directly, there are no artifacts. I have provided some samples in the attached zip file: audio_samples.zip
In my opinion, there are two fixes for this:
apply_pydub()
before converting to int16 [link] or the functionconvert_float_samples_to_int16()
[link] itself, e.g.,Edit:
eps
is probably not necessary in fix (1).Thanks in advance!