asteroid-team / torch-audiomentations

Fast audio data augmentation in PyTorch. Inspired by audiomentations. Useful for deep learning.
MIT License
928 stars 87 forks source link

Empty ValueError raised during augmentation #155

Open rafaelgreca opened 2 years ago

rafaelgreca commented 2 years ago

Hello!

I am doing augmentation on a bunch of audio files using batches, but somewhere in between I am getting an empty ValueError error. I know this error is coming from the io.py file located inside the utils folder (more precisely here), but I don't know what is causing it and how to fix it.

Any ideas on how to work around this issue?

Thanks in advance!

iver56 commented 2 years ago

@hbredin Can you imagine why this would happen? The code does raise ValueError() without giving a specific error message. How can we improve the code?

hbredin commented 2 years ago

Most likely an off-by-one rounding error due to https://github.com/asteroid-team/torch-audiomentations/blob/1590056ba3bbb06a75e24fb4bcec0fd10569a083/torch_audiomentations/utils/io.py#L232 and https://github.com/asteroid-team/torch-audiomentations/blob/1590056ba3bbb06a75e24fb4bcec0fd10569a083/torch_audiomentations/utils/io.py#L238

I believe using math.floor instead of round should fix the issue and we could safely remove the check that raises the ValueError.

@rafaelgreca could you by any chance find a way for us to reproduce the error? You could just replace raise ValueError() by something like

raise ValueError(f"{audio_path=} {sample_offset=} {num_samples=}")

to find the faulty input argument combination.