librosa/librosa_gallery

Document the environment where examples work

Closed this issue · 13 comments

I mainly played around with '03-Vocal_separation.ipynb', which gives errors on plotting the spectrum + the final sound clips are nonsense. Quick check shows that other examples are not fully working either.

What i have tried (with no improvement):

  • Use Python 2 instead of Python 3
  • Downgrade Numpy to 1.13.0
  • Downgrade librosa to 4.6

@bmcfee Could you provide the output of pip freeze so i could set up working environment?

That's a great suggestion, thanks for noting this. I'll try to update the docs this week some time.

FWIW, I use conda environments, and just tested the vocal separation example, which seems to work as expected. Here's a gist of my current environment.

It might also make sense to escalate this upstream to sphinx-gallery, as it seems like a much more general problem than just librosa's gallery. @choldgraf what do you think?

Thanks, i tried your conda environment but still have same problems (i had to remove some packages that were not available, but i dont think this is the cause).

Tomorrow i will test on different computers and try to pinpoint the problem. Current system is Ubuntu 16.04 - usually python/notebook related stuff work without problems.

If you could log the problems you're having, it would help a lot.

1 Broken plots

In notebook 03-Vocal_separation, there are two cells starting with # Plot a 5-second slice of the spectrum. First one runs fine, while the second one fails due to empty array error.

Parts of the code that resolve to empty array:

>>> idx = slice(*librosa.time_to_frames([10, 15], sr=sr))
slice(861, 1291, None)

>>> S_full[:, idx]**2 # this is fed into `librosa.display.specshow`
array([], shape=(1025, 0), dtype=float32)

idx is also used in later cells...breaking these plots aswell.

2 Output audio broken

Audio(data=y, rate=sr) # plays correctly, 30 sec

Audio(data=librosa.istft(S_background * phase), rate=sr) # 7 sec, noise?
Audio(data=librosa.istft(S_foreground * phase), rate=sr) # 7 sec, maybe sounds like speeded up lyrics?

I have now tested this on 3 additional systems:

  1. Ubuntu 17.10, Python 3.6.3 :: Anaconda, Inc. -> same problems
  2. Ubuntu 17.10, Python 3.6.3 (system) -> same problems
  3. Ubuntu 14.04, Python 3.6.3 and Python 3.5 :: Anaconda, Inc. -> same problems, also fails to play 30 sec clips with IOPub data rate exceeded

I will continue investigating. Looks like this could be OS related?

Tried on Windows 10 - exactly the same behavior.

System: Python 3.5.2 :: Anaconda 4.1.1 (64-bit)
Installed from requirements.txt - after had to upgrade numba and install ffmpeg.

@bmcfee do you have any ideas about this?

A couple of thoughts:

  1. Since the input audio plays back correctly, I don't think it's a platform error. Those usually manifest as codec problems, and that seems to be working just fine.
  2. Are you using the provided input example, or a different audio file? What's the shape of S_full?

No changes to the notebook.

>>> S_full, phase = librosa.magphase(librosa.stft(y, hop_length=2048, window=np.ones))
>>> S_full.shape
(1025, 646)

I think i have fixed it now, hop_length=2048 should be removed from the stft call:

>>> S_full, phase = librosa.magphase(librosa.stft(y, window=np.ones))
(1025, 2584)

After this i have working plots and 30 sec outputs with decent quality.
The fact that the notebook worked in your environment kind of threw me off... maybe you have uncommited change in the notebook?

Aha, the hop length is different? You need to propagate that through to the istft call and time_to_frames conversion.

Hrm. When you say "the notebook", do you mean the notebook generated on download from the live gallery, or the one that lives in the repo?

Hmm.. i cloned the repo and used notebooks from there. Didnt even realize there is a web-gallery with updated version...
Still, it would be nice to get working notebooks on clone.

Also, repo notebooks could be turned into unit-tests with nbval and nbdime and integrated to the CI. I might be able to work on this if there is interest.

Ah. Actually I think the notebooks should be removed, since sphinx-gallery can generate them from the example .py scripts, and that way we only have one canonical source of the code. I'll stick that on the ol' to-do!

Glad we found a solution, thanks.