beetbox / beets

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

Error in autobpm module (at least with Python 3.7) #5289

Open cybersphinx opened 3 weeks ago

cybersphinx commented 3 weeks ago

Problem

Trying to import an album with the new autobpm plugin, first I had to install librosa and resampy to get it to run, those dependencies should probably be documented.

Then it failed with:

Traceback (most recent call last):
  File "/home/user/bin/beet", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/ui/commands.py", line 1395, in import_func
    import_files(lib, paths, query)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/ui/commands.py", line 1326, in import_files
    session.run()
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/util/pipeline.py", line 447, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/util/pipeline.py", line 195, in coro
    func(*(args + (task,)))
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/importer.py", line 1661, in plugin_stage
    func(session, task)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beets/plugins.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beetsplug/autobpm.py", line 49, in imported
    self.calculate_bpm(task.imported_items())
  File "/home/user/.local/pipx/venvs/beets2/lib/python3.7/site-packages/beetsplug/autobpm.py", line 82, in calculate_bpm
    bpm = round(tempo)
TypeError: type numpy.ndarray doesn't define __round__ method

Adding an import numpy and changing the indicated line to bpm = numpy.round(tempo) fixed it here. Might just be a Python 3.7 problem, but the 2.0.0 release notes still claim Python 3.7 support.

Setup

tumbleboy commented 2 weeks ago

Hey! I can create a pull request with the suggested change if it's suitable.