Closed hbredin closed 2 years ago
Thanks for filing this. Yeah, low == high isn't properly supported yet in this transform. I guess it could be patched by using torch.full, like here: https://github.com/asteroid-team/torch-audiomentations/blob/cf33679368125b0ff6db6680a7cf0b289386849f/torch_audiomentations/augmentations/shift.py#L119
As a workaround until it is fixed, one can do something like this, which for all practical intents and purposes gives the same result:
AddBackgroundNoise(
bg_path, min_snr_in_db=12.0, max_snr_in_db=12.0000001
)
If you'd like to contribute, that would be a welcome PR 😄
@FrenchKrab I think I noticed this max_snr = min_snr + epsilon
hack in your code.
Would you like to contribute this change?
I opened a PR that adds the suggested torch.full fix
Thanks
torch.distributions.Uniform
raises a ValueError whenlow == high
:AddBackgroundNoise
only raises whenmin_snr_in_db > max_snr_in_db
, and not whenmin_snr_in_db == max_snr_in_db
There is therefore an inconsistency between the two behaviors.
I think supporting
min == max
is the way to go.