beetbox / pyacoustid

Python bindings for Chromaprint acoustic fingerprinting and the Acoustid Web service
MIT License
332 stars 66 forks source link

Fingerprint result with force fpcalc is other than with default settings #68

Open garlontas opened 3 years ago

garlontas commented 3 years ago

Hello! I'm developing an application using your library and I had the problem that I didn't get any result with the default fingerprinting. (acoustid.match(self.__API_KEY, self.__file)) :disappointed: Then I used acoustid.match(self.__API_KEY, self.__file, force_fpcalc=True) and I received the data I needed. :+1: Maybe you could take a look at this problem. A possible solution would be setting fpcalc as the default finger printer.

PS: It also occurs using your aidmatch.py script

sampsyo commented 3 years ago

Is there a way you can describe to reproduce the problem?

garlontas commented 3 years ago

So first I had this code:

        try:
            results = acoustid.match(self.__API_KEY, self.__file)
        except acoustid.NoBackendError:
            raise error.ChromaprintNotFoundException(
                "Chromaprint library/tool not found")
        except acoustid.FingerprintGenerationError:
            raise error.FingerprintGenerationError(
                "Fingerprint could not be calculated")
        except acoustid.WebServiceError as exc:
            raise error.WebServiceError("Web service request failed:", exc.message)
        try:
            result = next(results)
        except StopIteration as exc:
            raise error.FingerprintGenerationError(
                "Fingerprint could not be calculated") from exc
        self.__id = result[1]
        return self.__id

When I run that code, your pyacoustid calculates the fingerprint with the default calculator, and it fails with the StopIteration error because the generator is empty.

Afterwards I changed the code and wrote this:

        try:
            results = acoustid.match(self.__API_KEY, self.__file, force_fpcalc=True)
        except acoustid.NoBackendError:
            raise error.ChromaprintNotFoundException(
                "Chromaprint library/tool not found")
        except acoustid.FingerprintGenerationError:
            raise error.FingerprintGenerationError(
                "Fingerprint could not be calculated")
        except acoustid.WebServiceError as exc:
            raise error.WebServiceError("Web service request failed:", exc.message)
        try:
            result = next(results)
        except StopIteration as exc:
            raise error.FingerprintGenerationError(
                "Fingerprint could not be calculated") from exc
        self.__id = result[1]
        return self.__id

Now everything worked, and I got no errors (fpcalc version 1.4.3)

The file I tested with has the fpcalc result: result.txt

swanux commented 3 years ago

I can confirm this issue, I have the exact same problem.

OS: elementaryOS 6 (Ubuntu 20.04) chromaprint: 1.4.3 (distribution provided)