torch-audiomentations icon indicating copy to clipboard operation
torch-audiomentations copied to clipboard

No fast pitch-shift ratios could be computed for the given sample rate and transpose range.

Open Crazylov3 opened this issue 3 years ago • 13 comments

I use PitchShift wih min=-0.9 and max = 1.1, then it raise No fast pitch-shift ratios could be computed for the given sample rate and transpose range.. I dont face with this error when use cpu version github. Do you have any plan to fix it?

Crazylov3 avatar Jul 02 '22 03:07 Crazylov3

Hey

Does it work if you use 0.9 instead of -0.9?

iver56 avatar Jul 02 '22 08:07 iver56

And what do you mean with cpu version github? Are you refering to https://github.com/iver56/audiomentations?

iver56 avatar Jul 02 '22 08:07 iver56

What's the sample rate?

iver56 avatar Jul 02 '22 08:07 iver56

Hey

Does it work if you use 0.9 instead of -0.9?

No, It doesn't

Crazylov3 avatar Jul 02 '22 09:07 Crazylov3

What's the sample rate? it is 8000

Crazylov3 avatar Jul 02 '22 09:07 Crazylov3

And what do you mean with cpu version github? Are you refering to https://github.com/iver56/audiomentations?

Yep, that what i mean.

Crazylov3 avatar Jul 02 '22 09:07 Crazylov3

Oh, that is indeed a low sample rate. Maybe you can use audiomentations for now then, since it works there

@KentoNishi Have you tried torch-pitch-shift with sr=8000?

iver56 avatar Jul 02 '22 12:07 iver56

Torch-pitch-shift works fine, thank you!

Crazylov3 avatar Jul 02 '22 12:07 Crazylov3

Good :) torch-audiomentations actually depends on torch-pitch-shift, but uses its get_fast_shifts feature. So yeah, if you use torch-pitch-shift directly without get_fast_shifts, it'll probably work.

iver56 avatar Jul 02 '22 12:07 iver56

Good to hear that it works!

KentoNishi avatar Jul 02 '22 16:07 KentoNishi

I have the same issue (version=0.11.0) with sample_rate = 16000 and (min, max)=(-0.2, 0,2). However, when the range changed to (-0.5, 0.5), the error didn't appear. In my case, the original dataset is piano sounds, so too much altering pitches can produce invalid data. Therefore, increasing the range is not a solution. I have also tested torch_pith_shift. It works sometimes, but due to extensive memory consumption, the program crashed randomly for some shift values (for example, -0.16093115439744646).

Also, the running time dramatically increased after using PitchShift transform. In my laptop and using six other transformations, the average augmentation time per example (10s) is

setting average augmentation time per example (s)
without PitchShift 0.026
with PitchShift 0.232
with pitch_shift function of torch_pith_shift 3.951

AliKarimi95 avatar Aug 23 '22 16:08 AliKarimi95

Pitch shifts are generally pretty intensive operations so I'm not too surprised about the increase in execution time. Regarding speed issues with some pitch shift factors, unfortunately some factors aren't ideal for speed, so the rate of data transfer to the GPU becomes the bottleneck. In your specific case, it may be better to apply cpu-based pitch shift instead.

KentoNishi avatar Aug 23 '22 18:08 KentoNishi

That's an interesting use case, AliKarimi95

Note: Although the pitch shift transform in torch-audiomentations can be comparatively fast on GPU, it is slow on CPU. When running pitch shift on CPU, the one in audiomentations is roughly 3x as fast.

iver56 avatar Aug 23 '22 18:08 iver56