beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.58k stars 1.8k forks source link

Crash in autobpm plugin / Docs incomplete #5185

Open JOJ0 opened 2 months ago

JOJ0 commented 2 months ago

Sorry for being brief. A quick report on a crash I'm experiencing with the rather new autobpm plugin. Something with librosa. I'm on Python 3.11.

Problem

Running this command in verbose (-vv) mode:

$ beet -vv autbpm label:syncopathic

Led to this problem:

Traceback (most recent call last):
  File "/home/jojo/.pyenv/versions/beets/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jojo/git/beets/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/home/jojo/git/beets/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/jojo/git/beets/beetsplug/autobpm.py", line 46, in command
    self.calculate_bpm(lib.items(ui.decargs(args)), write=ui.should_write())
  File "/home/jojo/git/beets/beetsplug/autobpm.py", line 81, in calculate_bpm
    tempo, _ = beat.beat_track(y=y, sr=sr)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jojo/.pyenv/versions/3.11.3/envs/beets/lib/python3.11/site-packages/librosa/beat.py", line 185, in beat_track
    beats = __beat_tracker(onset_envelope, bpm, float(sr) / hop_length, tightness, trim)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jojo/.pyenv/versions/3.11.3/envs/beets/lib/python3.11/site-packages/librosa/beat.py", line 433, in __beat_tracker
    beats = __trim_beats(localscore, beats, trim)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jojo/.pyenv/versions/3.11.3/envs/beets/lib/python3.11/site-packages/librosa/beat.py", line 507, in __trim_beats
    smooth_boe = scipy.signal.convolve(localscore[beats], scipy.signal.hann(5), "same")
                                                          ^^^^^^^^^^^^^^^^^
AttributeError: module 'scipy.signal' has no attribute 'hann'

Here's a link to the music files that trigger the bug (if relevant):

difficult to provide....

Setup

Also a quick note on the existing docs: https://docs.beets.io/en/latest/plugins/autobpm.html

The installation requirements could be better. We need to pip install librosa resampy as far as I figured it out. That correct? We should explicitely state that in the docs

JOJ0 commented 2 months ago

@tandy-1000 Hi :-) Just a heads up. Maybe you have seen this issue? And also note that we should improve the docs a little here. Please clarify if my pip install assumption are correct, I'll correct the issue description then :-)

wisp3rwind commented 2 months ago

Looks like a simple bug in librosa, though: https://github.com/librosa/librosa/issues/1830 (i.e. librosa uses scipy < 1.0.0API).