beetbox / beets

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

Chroma plugin errors out #2216

Closed dgiffen closed 8 years ago

dgiffen commented 8 years ago
Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.19', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 197, in fingerprint_cmd_func
    fingerprint_item(self._log, item, write=ui.should_write())
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 298, in fingerprint_item
    _, fp = acoustid.fingerprint_file(item.path)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview

Problem

(Describe your problem, feature request, or discussion topic here. If you're reporting a bug, please fill out this and the "Setup" section below. Otherwise, you can delete them.)

Running this command in verbose (-vv) mode:

$ beet -vv (... paste here ...)

Led to this problem:

(paste here)

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

Setup

My configuration (output of beet config) is:

(paste here)
sampsyo commented 8 years ago

Can you please verify that you have the latest versions of audioread and pyacoustid?

(In the future, if you're not going to use the issue template, please just delete it. :confused:)

dgiffen commented 8 years ago

yes I have the newest pyacoustid according to Pip upgrade Audioread is 2.1. 4 I have this working on another ubuntu box for the last couple of years. I also installed newest ffmpeg in ubuntu repos plus the gstreamer plugins

sampsyo commented 8 years ago

This might be related to https://github.com/beetbox/pyacoustid/pull/31 in pyacoustid. Do you happen to have pymad installed?

dgiffen commented 8 years ago

Oops on closing, wrong button. I do have pymad installed. I think while trying to get it to work, I installed every possible package hoping the next one would be the magic bullet to fix this.

sampsyo commented 8 years ago

OK, cool. Here are a couple of ways to follow up:

Beyond this, we'll need to think about in situ debugging…

dgiffen commented 8 years ago

Traceback (most recent call last): File "/usr/local/bin/beet", line 9, in load_entry_point('beets==1.3.19', 'console_scripts', 'beet')() File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1266, in main _raw_main(args) File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1253, in _raw_main subcommand.func(lib, suboptions, subargs) File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 967, in import_func import_files(lib, paths, query) File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 944, in import_files session.run() File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 320, in run pl.run_parallel(QUEUESIZE) File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run out = self.coro.send(msg) File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro func((args + (task,))) File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1257, in lookup_candidates plugins.send('import_task_start', session=session, task=task) File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 457, in send result = handler(__arguments) File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 123, in wrapper return func(_args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 143, in fingerprint_task return fingerprint_task(self._log, task, session) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 213, in fingerprint_task acoustid_match(log, item.path) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 65, in acoustid_match duration, fp = acoustid.fingerprint_file(util.syspath(path)) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file return _fingerprint_file_audioread(path, maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint fper.feed(block) File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed raise TypeError('data must be bytes, buffer, or memoryview') TypeError: data must be bytes, buffer, or memoryview

I uninstalled the pymad and tried with MP3 files. It error-ed out immediately.

sampsyo commented 8 years ago

OK, we're getting closer, but this is kind of the end of the road for what I can guess remotely. Is there any chance we could set up access so I can take a look directly—or would you be comfortable with inserting print statements to get more detail?

What you'd need to do is edit /usr/local/lib/python2.7/dist-packages/chromaprint.py to print which type of object is triggering the error. Then look in /usr/local/lib/python2.7/dist-packages/audioread.py to print out which decoding backend is producing those values.

dgiffen commented 8 years ago

I would be OK with adding print statements. Just let me know what and where to put it.

sampsyo commented 8 years ago

OK, great!

In chromaprint.py, please add print(type(data)) above this line: https://github.com/beetbox/pyacoustid/blob/master/chromaprint.py#L116 That is, at the top of the feed method body.

In acoustid.py, please add print(f) below this line: https://github.com/beetbox/pyacoustid/blob/master/chromaprint.py#L116 That is, just inside the with block.

Thank you for your help!

dgiffen commented 8 years ago

both of those statements are for the same file chromaprint not sure where to put it on the acoustid.py print(type(data)) if isinstance(data, BUFFER_TYPES):

sampsyo commented 8 years ago

Ack; sorry for pasting the wrong link in the second case. I meant this line in acoustid.py: https://github.com/beetbox/pyacoustid/blob/master/acoustid.py#L262

dgiffen commented 8 years ago

Traceback (most recent call last): File "/usr/local/bin/beet", line 9, in load_entry_point('beets==1.3.19', 'console_scripts', 'beet')() File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1266, in main _raw_main(args) File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1253, in _raw_main subcommand.func(lib, suboptions, subargs) File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 967, in import_func import_files(lib, paths, query) File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 944, in import_files session.run() File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 320, in run pl.run_parallel(QUEUESIZE) File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run out = self.coro.send(msg) File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro func((args + (task,))) File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1257, in lookup_candidates plugins.send('import_task_start', session=session, task=task) File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 457, in send result = handler(__arguments) File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 123, in wrapper return func(_args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 143, in fingerprint_task return fingerprint_task(self._log, task, session) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 213, in fingerprint_task acoustid_match(log, item.path) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 65, in acoustid_match duration, fp = acoustid.fingerprint_file(util.syspath(path)) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file return _fingerprint_file_audioread(path, maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint fper.feed(block) File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed raise TypeError('data must be bytes, buffer, or memoryview') TypeError: data must be bytes, buffer, or memoryview

sampsyo commented 8 years ago

Hmm; that doesn't include any of the new print statements. Can you please include that output, which will be above the traceback?

dgiffen commented 8 years ago
def _fingerprint_file_audioread(path, maxlength):
    """Fingerprint a file by using audioread and chromaprint."""
    print(f)
    try: 
        print(f)        this is where I added it
        with audioread.audio_open(path) as f:
            duration = f.duration
            fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
    except audioread.DecodeError:
        raise FingerprintGenerationError("audio could not be decoded")
    return duration, fp
dgiffen commented 8 years ago
File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.19', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 967, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 944, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 320, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1257, in lookup_candidates
    plugins.send('import_task_start', session=session, task=task)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 457, in send
    result = handler(**arguments)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 143, in fingerprint_task
    return fingerprint_task(self._log, task, session)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 213, in fingerprint_task
    acoustid_match(log, item.path)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 65, in acoustid_match
    duration, fp = acoustid.fingerprint_file(util.syspath(path))
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview

I must not have hit save on this one. I got this after I added the line

def feed(self, data):
        """Send raw PCM audio data to the fingerprinter. Data may be
        either a bytestring or a buffer object.
        print(type(data))      I added this line
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif not isinstance(data, bytes):
            raise TypeError('data must be bytes, buffer, or memoryview')
        _check(_libchromaprint.chromaprint_feed(
            self._ctx, data, len(data) // 2
        ))
dgiffen commented 8 years ago

I have no data above the traceback. I included exactly what is printed to terminal. Hopefully I place them correctly.

sampsyo commented 8 years ago

That's odd! I really don't know what else to try—those modifications should definitely have an effect. Note that even the line numbers haven't changed, so my only guess is that you've somehow modified the wrong copy of those files, but I don't really see how that's possible. Aside from that, I'm at a dead end.

dgiffen commented 8 years ago

I will try to gitclone the beets library. I will remove those 2 files prior to doing so. That way I will get any updates. Pip seems a bit behind. I see 1.4 is out, I have 1.3.8 and pip says it is most current. It really doesn't present a major issue. Most of my stuff isn't really untagged. Thanks for your help though. It's really an excellent program and with some effort on the user can do a great job. I will post again, if cloning solves anything

dgiffen commented 8 years ago

Do you think it is possible that the issue is this: on my working machine the two files are in one location / usr / local / lib / python2.7 / dist-packages /acoustid.py and the chroma The machine that does not work has 2 copies / usr / local / lib / python2.7 / dist-packages / / usr / lib / python2.7 / dist-packages / I edited this one, but maybe it was using the other. Which is the preferred way. The are not symlinks. I intalled it through ubuntu apt, so I would have assumed it would only place these in 1 location and symlink them if necessary

dgiffen commented 8 years ago

Issue solved for me. There were not only 2 versions of these, but 2 separate beets. I removed both beets folders and the re installed it with pip. I also copied and pasted a the working chroma from the other box. I got an error the first time and it cited the line I added. So I wanted to make sure I had a working chroma. all is good here, once again thank you for getting on this so fast. You effort is much appreciated.

sampsyo commented 8 years ago

Great; I'm glad that's working.

ghost commented 8 years ago

Hello, this is my first time on Git so please excuse the noobiness.

Firstly, my system details are:

Ubuntu 16.04 Beets version is 1.3.19 Audioread version 2.1.4 Pyacoustid version 1.1.2

I’m facing the same problem discussed under git issue numbers #1958 , #1829 and this one none of the solutions worked. In reference to a set of questions asked in pull request #31 I have the following installed with their version numbers

pymad 0.9-1 libgstreamer1.0 version 1.8.2-1 ffmpeg 7:2.8.6-lubuntu 2 python-gobject 3.20.0-oubuntu1 python-gi also 3.20.0-0ubuntu1

Also based on the suggestions made in pull request #31, I added print(type(data)) into chromaprint.py and print(f) into acoustid.py in /usr/bin/local/lib/python2.7/dist-packages. I have only one version of beets installed and running. Also uninstalling python-pymad made no difference.

Below is the error i receive

<audioread.gstdec.GstAudioFile object at 0x7f731722ca90>
<type 'str'>
Traceback (most recent call last):
  File "/home/username/.local/bin/beet", line 11, in <module>
    sys.exit(main())
  File "/home/username/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/home/username/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/username/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 967, in import_func
    import_files(lib, paths, query)
  File "/home/username/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 944, in import_files
    session.run()
  File "/home/username/.local/lib/python2.7/site-packages/beets/importer.py", line 320, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/username/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 301, in run
    out = self.coro.send(msg)
  File "/home/username/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 183, in coro
    func(*(args + (task,)))
  File "/home/username/.local/lib/python2.7/site-packages/beets/importer.py", line 1257, in lookup_candidates
    plugins.send('import_task_start', session=session, task=task)
  File "/home/username/.local/lib/python2.7/site-packages/beets/plugins.py", line 457, in send
    result = handler(**arguments)
  File "/home/username/.local/lib/python2.7/site-packages/beets/plugins.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 143, in fingerprint_task
    return fingerprint_task(self._log, task, session)
  File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 212, in fingerprint_task
    acoustid_match(log, item.path)
  File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 65, in acoustid_match
    duration, fp = acoustid.fingerprint_file(util.syspath(path))
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 322, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 265, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 120, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview
}

from the output of the print commands, it seems that chromaprint is returning a str and not a byte string but how do I fix it?

This is my beets.conf file


directory: ~/Music/Sorted
library: ~/Music/Data/musiclibrary.blb

import: 
    move: yes
    resume: ask
    incremental: yes
    log: beetslog.txt

ignore: .DS_Store Thumbs.db
ignore_hidden: yes

paths:
    default: %title{$albumartist} - %title{$album} ($year)%aunique{}

plugins: embedart lastgenre scrub chroma
puginpath: ~/beets/myplugins

ui:
    color: yes
    colors:
        text_success: green
        text_warning: yellow
        text_error: red
        text_highlight: red
        text_highlight_minor: lightgray
        action_default: turquoise
        action: blue

match:
    strong_rec_thresh: 0.25

Any help would be appreciated.

sampsyo commented 8 years ago

Thanks for trying out the print commands, @Joeslavins! This really helps.

Here's where we're at. Your output amounts to:

<type 'str'>
[...]
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 120, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')

Can you please confirm that the relevant part of your chromaprint.py is exactly this?

        print(type(data))
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif not isinstance(data, bytes):
            raise TypeError('data must be bytes, buffer, or memoryview')

If that's the case, I'm extremely mystified. The output says the type is str, which is an alias for bytes under Python 2.7. In other words:

>>> data = b'test'
>>> print(type(data))
<type 'str'>
>>> print(isinstance(data, bytes))
True

which means it should be impossible for the elif branch to fire and raise the exception.

I'm not sure what else to try, but maybe you can try inserting this print statement (right below the other one) just to check our sanity?

print(isinstance(data, bytes))
ghost commented 8 years ago

Dear @sampsyo,

Thank you for your reply

I checked the chromaprint.py file, it wasn't the same, instead it was


print(type(data))
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif not isinstance(data, bytearray):
            raise TypeError('data must be bytes, buffer, or memoryview')

So i changed it to bytes and inserted the print(isinstance(data, bytes)) command as you requested and now the relevant section of my chromaprint looks like


print(type(data))
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif not isinstance(data, bytes):
        print(isinstance(data, bytes))
            raise TypeError('data must be bytes, buffer, or memoryview')
        _check(_libchromaprint.chromaprint_feed(
            self._ctx, data, len(data) // 2
        ))

As a result of these changes the error has changed to

<audioread.maddec.MadAudioFile object at 0x7fb2053cf390> 
<type 'bytearray'> 
False 
Traceback (most recent call last): 
 File "/home/username/.local/bin/beet", line 11, in <module> 
   sys.exit(main()) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1266, in main 
   _raw_main(args) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main 
   subcommand.func(lib, suboptions, subargs) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 967, in import_func 
   import_files(lib, paths, query) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/ui/commands.py", line 944, in import_files 
   session.run() 
 File "/home/username/.local/lib/python2.7/site-packages/beets/importer.py", line 320, in run 
   pl.run_parallel(QUEUE_SIZE) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 301, in run 
   out = self.coro.send(msg) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/util/pipeline.py", line 183, in coro 
   func(*(args + (task,))) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/importer.py", line 1257, in lookup_candidates 
   plugins.send('import_task_start', session=session, task=task) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/plugins.py", line 457, in send 
   result = handler(**arguments) 
 File "/home/username/.local/lib/python2.7/site-packages/beets/plugins.py", line 123, in wrapper 
   return func(*args, **kwargs) 
 File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 143, in fingerprint_task 
   return fingerprint_task(self._log, task, session) 
 File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 212, in fingerprint_task 
   acoustid_match(log, item.path) 
 File "/home/username/.local/lib/python2.7/site-packages/beetsplug/chroma.py", line 65, in acoustid_match 
   duration, fp = acoustid.fingerprint_file(util.syspath(path)) 
 File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 322, in fingerprint_file 
   return _fingerprint_file_audioread(path, maxlength) 
 File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 265, in _fingerprint_file_audioread 
   fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength) 
 File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint 
   fper.feed(block) 
 File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 121, in feed 
   raise TypeError('data must be bytes, buffer, or memoryview') 
TypeError: data must be bytes, buffer, or memoryview

Maybe this means that the fault now lies with acoutsid.py? I'm pasting the relevant section of acoutsid.py below.


def _fingerprint_file_audioread(path, maxlength):
    """Fingerprint a file by using audioread and chromaprint."""
    try:
        with audioread.audio_open(path) as f:
            print(f)
            duration = f.duration
            fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
    except audioread.DecodeError:
        raise FingerprintGenerationError("audio could not be decoded")
    return duration, fp

If this doesn't help diagnose the issue, do you think uninstalling everything reinstalling would help? If so would you mind telling me 1) Which programs to remove and in which order should i uninstall them? 2) Whether i should use pip2 or apt-get to remove them. If apt-get then should I use the purge or remove command?

Alternatively can I clone chromaprint.py and acoustid.py from git and paste them in my /usr/local/lib/python2.7/dist-packages. If so can you tell me how to use the gitclone command, I'm new to it.

Thank you for your help with this, I think beets is an amazing software and you have my full cooperation in solving this.

sampsyo commented 8 years ago

OK! Thank you for all these details!

Something very weird is going on here. Your chromaprint.py file has this line:

elif not isinstance(data, bytearray):

which isn't the line in the source: https://github.com/beetbox/pyacoustid/blob/master/chromaprint.py#L118

In fact, as far as I can tell, no version of the library has ever had that line. I really don't know where that came from.

You mentioned you're on Ubuntu. Did you install pyacoustid from the apt-get package repositories or from pip? If you installed from Ubuntu's repositories, can you try uninstalling that and installing from pip instead?

sampsyo commented 8 years ago

As further documentation: I checked the entire git history of the project, and we've never used bytearray.

$ git grep bytearray $(git rev-list --all)

I also checked out the Ubuntu package for 16.04, and it also doesn't seem to contain any bytearray references: https://launchpad.net/ubuntu/+source/pyacoustid

So I'm quite confused! I don't know where that could have come from.

dgiffen commented 8 years ago

Adrian, I removed it with the apt purge, then pip install. It says newest version. I copied and pasted the chroma.py from git and still get the following errors.

Traceback (most recent call last): File "/usr/local/bin/beet", line 9, in load_entry_point('beets==1.3.19', 'console_scripts', 'beet')() File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1266, in main _raw_main(args) File "/usr/local/lib/python2.7/dist-packages/beets/ui/init.py", line 1253, in _raw_main subcommand.func(lib, suboptions, subargs) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 197, in fingerprint_cmd_func fingerprint_item(self._log, item, write=ui.should_write()) File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 298, in fingerprintitem , fp = acoustid.fingerprint_file(item.path) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 321, in fingerprint_file return _fingerprint_file_audioread(path, maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 264, in _fingerprint_file_audioread fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength) File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint fper.feed(block) File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 119, in feed raise TypeError('data must be bytes, buffer, or memoryview') TypeError: data must be bytes, buffer, or memoryview

I only get this on some files, MP3's and all of them already have a fingerprint. i do no know where the offending line is coming from. I for sure have not messed with that file, other than now.

Thanks Doug

On Mon, Oct 17, 2016 at 3:47 PM, Adrian Sampson notifications@github.com wrote:

As further documentation: I checked the entire git history of the project, and we've never used bytearray.

$ git grep bytearray $(git rev-list --all)

I also checked out the Ubuntu package for 16.04, and it also doesn't seem to contain any bytearray references: https://launchpad.net/ubuntu/+ source/pyacoustid

So I'm quite confused! I don't know where that could have come from.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/beetbox/beets/issues/2216#issuecomment-254313060, or mute the thread https://github.com/notifications/unsubscribe-auth/ADeL_XU98RPdrTRsC8TMf_xynUiQ3rU2ks5q09DrgaJpZM4KNrpa .

sampsyo commented 8 years ago

OK, cool—can you check again in that file and see whether it still has the mysterious bytearray line? If so, we'll have something else to debug…

dgiffen commented 8 years ago

Adrian, It does not have the line: elif not isinstance(data, bytes): I am assuming this is correct. Another thing if is helps is. I can move these files to my main computer and do the acoustic fingerprint with both puddletag and filebot. Both of which need fpcalc.

It works on 95% of files I have tried, just a few error out.

Thanks Doug

On Mon, Oct 17, 2016 at 4:12 PM, Adrian Sampson notifications@github.com wrote:

OK, cool—can you check again in that file and see whether it still has the mysterious bytearray line? If so, we'll have something else to debug…

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/beetbox/beets/issues/2216#issuecomment-254319511, or mute the thread https://github.com/notifications/unsubscribe-auth/ADeL_UMxXltb9GPedC_HQt1u8yQqIhV5ks5q09bDgaJpZM4KNrpa .

sampsyo commented 8 years ago

Yep, that's the right line.

Can you please try the print statement from above again?

dgiffen commented 8 years ago

Adrian, I will, but it will have to wait until tomorrow.

Thanks Doug

On Mon, Oct 17, 2016 at 4:31 PM, Adrian Sampson notifications@github.com wrote:

Yep, that's the right line.

Can you please try the print statement from above again?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/beetbox/beets/issues/2216#issuecomment-254324739, or mute the thread https://github.com/notifications/unsubscribe-auth/ADeL_VzOC3PR2zhqzsRiT6Zm5k0tlK5Jks5q09s_gaJpZM4KNrpa .

rwthompsonii commented 8 years ago

FWIW, I just ran into this issue myself.

When I modify this function:

def feed(self, data):
        """Send raw PCM audio data to the fingerprinter. Data may be
        either a bytestring or a buffer object.
        """
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif not isinstance(data, bytes):
            raise TypeError('data must be bytes, buffer, or memoryview')
        _check(_libchromaprint.chromaprint_feed(
            self._ctx, data, len(data) // 2
        ))

to this:

def feed(self, data):
        """Send raw PCM audio data to the fingerprinter. Data may be
        either a bytestring or a buffer object.
        """
        if isinstance(data, BUFFER_TYPES):
            data = str(data)
        elif isinstance(data, bytearray):
            data = bytes(data)
        elif not isinstance(data, bytes):
            raise TypeError('data must be bytes, buffer, or memoryview')
        _check(_libchromaprint.chromaprint_feed(
            self._ctx, data, len(data) // 2
        )

It runs without issue. That function is located in this location https://github.com/beetbox/pyacoustid/blob/master/chromaprint.py and on my box is located at path: /usr/local/lib/python2.7/dist-packages/chromaprint.py

This is just a heads up to anyone else that googles the error code and finds a github issue, which I find is always a bad sign. It's a hack and a workaround but I'm not the project maintainer, I just want it to work, I don't mind if it takes longer (because I just copied a crap ton of bytes unnecessarily, I'm assuming.)

sampsyo commented 8 years ago

Huh! Thanks for checking in, @rwthompsonii.

Any chance I could convince you to try inserting this other print statement I mentioned above?

In acoustid.py, please add print(f) below this line: https://github.com/beetbox/pyacoustid/blob/master/acoustid.py#L262 That is, just inside the with block.

That should help by printing out the root cause that's giving us bytearray values.

rwthompsonii commented 8 years ago

Sure. I'll get back to you tonight.

On Oct 27, 2016 7:56 PM, "Adrian Sampson" notifications@github.com wrote:

Huh! Thanks for checking in, @rwthompsonii https://github.com/rwthompsonii.

Any chance I could convince you to try inserting this other print statement I mentioned above?

In acoustid.py, please add print(f) below this line: https://github.com/beetbox/pyacoustid/blob/master/acoustid.py#L262 That is, just inside the with block.

That should help by printing out the root cause that's giving us bytearray values.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/beetbox/beets/issues/2216#issuecomment-256824403, or mute the thread https://github.com/notifications/unsubscribe-auth/AK32Uhu9RKpSu-ti41hj9Z4thh--eyF1ks5q4WRNgaJpZM4KNrpa .

rwthompsonii commented 8 years ago

commented out my code, put yours in. Here's the result:

beet import -L mann
<audioread.gstdec.GstAudioFile object at 0x7fc17c0c8390>
<audioread.gstdec.GstAudioFile object at 0x7fc17c057c10>
<audioread.gstdec.GstAudioFile object at 0x7fc17c04c810>
<audioread.gstdec.GstAudioFile object at 0x7fc1894a04d0>
<audioread.gstdec.GstAudioFile object at 0x7fc17c057910>
<audioread.gstdec.GstAudioFile object at 0x7fc17c04c0d0>
<audioread.gstdec.GstAudioFile object at 0x7fc17c057710>
<audioread.gstdec.GstAudioFile object at 0x7fc17c04c850>
<audioread.gstdec.GstAudioFile object at 0x7fc187c3dd90>
<audioread.gstdec.GstAudioFile object at 0x7fc17c19aa90>
<audioread.gstdec.GstAudioFile object at 0x7fc187c3db50>
<audioread.gstdec.GstAudioFile object at 0x7fc187c3d050>
<audioread.gstdec.GstAudioFile object at 0x7fc17c057410>
<audioread.maddec.MadAudioFile object at 0x7fc17c0576d0>
Traceback (most recent call last):
  File "/usr/local/bin/beet", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 967, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 944, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 320, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 301, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 183, in coro
    func(*(args + (task,)))
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 1257, in lookup_candidates
    plugins.send('import_task_start', session=session, task=task)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 457, in send
    result = handler(**arguments)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 143, in fingerprint_task
    return fingerprint_task(self._log, task, session)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 212, in fingerprint_task
    acoustid_match(log, item.path)
  File "/usr/local/lib/python2.7/dist-packages/beetsplug/chroma.py", line 65, in acoustid_match
    duration, fp = acoustid.fingerprint_file(util.syspath(path))
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 322, in fingerprint_file
    return _fingerprint_file_audioread(path, maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 265, in _fingerprint_file_audioread
    fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength)
  File "/usr/local/lib/python2.7/dist-packages/acoustid.py", line 206, in fingerprint
    fper.feed(block)
  File "/usr/local/lib/python2.7/dist-packages/chromaprint.py", line 121, in feed
    raise TypeError('data must be bytes, buffer, or memoryview')
TypeError: data must be bytes, buffer, or memoryview

looks like whatever <audioread.maddec.MadAudioFile object at 0x7fc17c0576d0> is makes it unhappy. No idea what that means.

rwthompsonii commented 8 years ago

Also, I have one of the files that causes that if you want it.

sampsyo commented 8 years ago

OK! Looks like the data is coming from pymad. That definitely narrows it down; thank you!

rwthompsonii commented 8 years ago

No problem. Let me know if you need more.

On Oct 27, 2016 9:18 PM, "Adrian Sampson" notifications@github.com wrote:

OK! Looks like the data is coming from pymad. That definitely narrows it down; thank you!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/beetbox/beets/issues/2216#issuecomment-256832723, or mute the thread https://github.com/notifications/unsubscribe-auth/AK32Uk32WD-cxm7yW2YEbhztHC9JMkoNks5q4XepgaJpZM4KNrpa .

sampsyo commented 8 years ago

Thanks to everyone's sleuthing, I was able to track down the problem to this commit: https://github.com/jaqx0r/pymad/commit/0231d165dcc192e769b9480cbe5bc2586feb8fc1#comments

The pymad library changed the type it returns from buffer to bytearray in version 0.9. I've since fixed pyacoustid to accept this type. This should resolve itself as we publish the new version of that module.

Thanks for bearing with us!