0

So i am using the datasketch library to find if the audio 2 and audio 3 are similar to the audio 1. However even at the threshold=1 where it should only output audios that are 100% same, it shows the out of the other 2 audios aswell which are really different from the 1st audio. The link to the audios All of them are different audios but with same 29second length

from datasketch import MinHash , MinHashLSH

x1 , Sr1 = librosa.load(r'path\f1.mp3')
mfcc1 = librosa.feature.mfcc(y=x1 , sr=Sr1)
mfcc1 = mfcc1.tobytes()

x2 , Sr2 = librosa.load(r'path\f2.mp3')
mfcc2 = librosa.feature.mfcc(y=x2 , sr=Sr2)
mfcc2 = mfcc2.tobytes()

x3 , Sr3 = librosa.load(r'path\f3.mp3')
mfcc3 = librosa.feature.mfcc(y=x3 , sr=Sr3)
mfcc3 = mfcc3.tobytes()

minhash1 = MinHash(num_perm=128 , hashfunc=hash)
minhash2 = MinHash(num_perm=128 , hashfunc=hash)
minhash3 = MinHash(num_perm=128 , hashfunc=hash)

for col1 in mfcc1:
    minhash1.update(col1)

for col2 in mfcc2:
    minhash2.update(col2)

for col3 in mfcc3:
    minhash3.update(col3)

lsh = MinHashLSH(threshold= 1 , num_perm=128)
lsh.insert("minhash2",minhash2)
lsh.insert("minhash3",minhash3)
result=lsh.query(minhash1)
print(result)
  • How long are the audio files? In which way are they similar/different? Are the similar files aligned well with eachother? Is the audio that is similar the same length? Can you upload the audio files? – Jon Nordby Feb 13 '23 at 19:09
  • @JonNordby the audios are 29 seconds long, 2 of them are hard rock but from different songs and one of them is a much soothing song. I have uploaded the link to the 3 files you can download them from there. it would be a really big blessing if you could help me fix the code, this is my first time working with this library and there's not much information available about it on the internet – Faizan Ul Haq Feb 14 '23 at 16:08
  • So the goal is to determine musical similarity? On the level of sections of a song? Is it a requirement to use the datasketch library? It does not seem particularly geared for this task. – Jon Nordby Feb 14 '23 at 19:18
  • @JonNordby the task is to show an output which audio is similar to a query audio inputted. the threshold is set e.g 0.6 which is 60%, any audio that is above this threshold is to be outputted. I could only find this library for doing this task, however if you could recommend some other that would be helpful too. however this task is to be implemented using mfcc, minhashing and locality sensitive hashing algorithm – Faizan Ul Haq Feb 14 '23 at 20:05

0 Answers0