Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cybersphinx opened this issue Jun 7, 2024 · 4 comments · Fixed by #5389
Closed

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

cybersphinx opened this issue Jun 7, 2024 · 4 comments · Fixed by #5389
Assignees
Labels
bug bugs that are confirmed and actionable

Comments

@cybersphinx
Copy link

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
tumbleboy added a commit to tumbleboy/beets that referenced this issue Jun 17, 2024
@tumbleboy
Copy link

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

tumbleboy added a commit to tumbleboy/beets that referenced this issue Jun 18, 2024
@tumbleboy tumbleboy mentioned this issue Jun 18, 2024
3 tasks
@imposterdroids
Copy link

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

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

@snejus snejus added the bug bugs that are confirmed and actionable label Aug 15, 2024
@snejus snejus self-assigned this Aug 15, 2024
@snejus snejus linked a pull request Aug 16, 2024 that will close this issue
3 tasks
snejus added a commit that referenced this issue Aug 26, 2024
Fixes #5289 and #5185

Tried using the `autobpm` plugin and found a couple of issues:

1. #5185 `librosa` dependency was missing in `pyproject.toml`
2. Simply including the plugin in the configuration made `beet` take
over 4 seconds to start up.
3. BPM detection failed due to another missing dependency, `resampy`
4. #5289 Librosa `beat_track` function returned unexpected type which
made the plugin and the entire import process fail.

Addressed each of the above, slightly refactored the plugin and added
tests.
@rsc3
Copy link

rsc3 commented Sep 15, 2024

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

@Routhinator
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants