asteroid-team / torch-audiomentations

Fast audio data augmentation in PyTorch. Inspired by audiomentations. Useful for deep learning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Crazylov3 opened this issue · 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?

Hey

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

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

What's the sample rate?

Hey

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

No, It doesn't

What's the sample rate?
it is 8000

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

Yep, that what i mean.

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?

Torch-pitch-shift works fine, thank you!

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.

Good to hear that it works!

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

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.

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.