noisereduce icon indicating copy to clipboard operation
noisereduce copied to clipboard

Disabled TQDM is still on

Open Borda opened this issue 3 years ago • 5 comments

Hello, I have suspicion that the TQDM disabling does not work properly when another tqdm progress bar is already in use

image

and the used function is:

import torchaudio
import noisereduce as nr

def create_spectrogram(fname, reduce_noise: bool = False):
    waveform, sample_rate = torchaudio.load(fname, normalize=True)
    waveform = waveform[0]
    if reduce_noise:
        waveform = torch.tensor(nr.reduce_noise(y=waveform, sr=sample_rate, win_length=256, use_tqdm=False, n_jobs=-1))
    transform = torchaudio.transforms.Spectrogram(n_fft=3600, win_length=256)
    spectrogram = transform(waveform)
    return torch.log(spectrogram).numpy()

Borda avatar Feb 18 '22 12:02 Borda

Hm, I just tried to reproduce your error and don't get the same error with just another progress bar in use: https://colab.research.google.com/drive/1J_cu_bmow2j-x6LEnrRfHbaC7UqxoAU9?usp=sharing

Maybe it's some interaction between torchaudio and tqdm? Can you try embedding some non-noisereduce tqdm bar in your function and see if the error persists?

timsainb avatar Feb 18 '22 13:02 timsainb

I am running it in this notebook https://www.kaggle.com/jirkaborovec/birdclef-convert-spectrograms-noise-reduce and I see the multiple bars only with reduce_noise=True

Borda avatar Feb 18 '22 14:02 Borda

Yes, I'm trying to figure out where your error is coming from.

In noisereduce, I call tqdm here: tqdm(pos_list, disable=self.use_tqdm)

So I am suggesting you try adding a tqdm(range(10), disable=True) in the line above nr.reduce noise in your function. If you find that that tqdm bar also shows, you'll know if the error is unrelated to noisereduce.

timsainb avatar Feb 18 '22 14:02 timsainb

So I am suggesting you try adding a tqdm(range(10), disable=True) in the line above nr.reduce noise in your function. If you find that that tqdm bar also shows, you'll know if the error is unrelated to noisereduce.

tried and do not see the 10-step progress bar

Borda avatar Feb 18 '22 14:02 Borda

Ok, well I can't reproduce your error, so I'll just leave this open. tqdm is referenced once in the package (https://github.com/timsainb/noisereduce/blob/master/noisereduce/noisereduce.py#L224), and the disable flag is set to use_tqdm. So I can't see where the error would arise.

timsainb avatar Feb 18 '22 15:02 timsainb