akgupta1337 / Shazzam-Clone

A Python project for audio fingerprinting using the Shazam algorithm. It utilizes libraries like NumPy, PyDub, Matplotlib, and SciPy to extract audio features, generate hashes, and compare audio signatures for song identification.
1 stars 2 forks source link

Whats the logic for this function? #4

Open yasirysr47 opened 8 months ago

yasirysr47 commented 8 months ago

https://github.com/akgupta1337/Shazzam-Clone/blame/75b18e81d8cfbfc10710b79d5227942ee405dbec/logic/Shazzam.py#L75C2-L77C2

akgupta1337 commented 8 months ago

the function hash logic is a lambda function that takes 3 arguments freq1, freq2, offset. inside this function: -the string f"{freq1}|{freq2}|{offset}" is created, concatenating the three arguments separated by the pipe character |. -then it is encoded to byte datatype using UTF-8 encoding -the hashlib.sha1() computes the hash for this encoded string -the hex digest function is called to convert this hash value to hexadecimal format -finally the hexadecimal hash is sliced including only the first 25 characters to save memory