itspoma / audio-fingerprint-identifying-python

The Shazam-similar app, that identify the song using audio fingerprints & spectrum analysis and Fast Fourier transform
MIT License
351 stars 164 forks source link

Updated codes to Python 3.6 showing error #14

Closed executable16 closed 4 years ago

executable16 commented 4 years ago

@itspoma

I forked this repo and updated the python files to Python 3.6. But on running the command make fingerprint-songs

I get these errors.

Traceback (most recent call last):
  File "collect-fingerprints-of-songs.py", line 54, in <module>
    channel_hashes = set(channel_hashes)
  File "/home/executable/Desktop/audio-fingerprint-identifying-python/libs/fingerprint.py", line 168, in generate_hashes
    h = hashlib.sha1("%s|%s|%s" % (str(freq1), str(freq2), str(t_delta)))
TypeError: Unicode-objects must be encoded before hashing
sqlite - connection has been closed
make: *** [Makefile:19: fingerprint-songs] Error 1
ryanhammonds commented 4 years ago

In fingerprint.py, changing this in the line 167 (or 168 in your traceback) :

h = hashlib.sha1("%s|%s|%s" % (str(freq1), str(freq2), str(t_delta)))

to this:

hash_string = "%s|%s|%s" % (str(freq1), str(freq2), str(t_delta))
h = hashlib.sha1(hash_string.encode('utf-8'))

worked for me.

executable16 commented 4 years ago

Great. You might run into another problem on running make recognize-listen seconds=5. If you fix that, it would be great however I have fixed that but I am just unsure, if it's okay and legit.

On Fri, May 1, 2020 at 6:31 AM Ryan Hammonds notifications@github.com wrote:

In fingerprint.py, changing this in the line 167 :

h = hashlib.sha1("%s|%s|%s" % (str(freq1), str(freq2), str(t_delta)))

to this:

hash_string = "%s|%s|%s" % (str(freq1), str(freq2), str(t_delta)) h = hashlib.sha1(hash_string.encode('utf-8'))

worked for me.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/itspoma/audio-fingerprint-identifying-python/issues/14#issuecomment-622197770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJQSAJKIZBCYM3ZINNNYC43RPINOPANCNFSM4MLI5KFA .

itspoma commented 4 years ago

Thanks everyone! If you think that would help others, please create PR.

Cheers, Roman