beets icon indicating copy to clipboard operation
beets copied to clipboard

Error in autobpm module (at least with Python 3.7)

Open cybersphinx opened this issue 1 year ago • 1 comments

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

  • OS: Debian 10.13
  • Python version: 3.7.3
  • beets version: 2.0.0
  • Turning off plugins made problem go away (yes/no): Fixing the plugin made the problem go away

cybersphinx avatar Jun 07 '24 23:06 cybersphinx

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

tumbleboy avatar Jun 17 '24 05:06 tumbleboy

Ran into this yesterday before checking the forums. I changed one line as a quick fix.

bpm = int(tempo.round()[0])

imposterdroids avatar Jul 08 '24 02:07 imposterdroids

Encountered the same issue with autobpm and python 3.10 and beets 2.0, used the fix above.

rsc3 avatar Sep 15 '24 21:09 rsc3

Ran into this yesterday before checking the forums. I changed one line as a quick fix.

bpm = int(tempo.round()[0])

This fix is no good when a float is encountered, also the tempo object is a numpy type and the numpy.round() suggestion in the PR fixed this in all edge cases for me.

Routhinator avatar Sep 19 '24 21:09 Routhinator