I am getting audio fingerprints from sound clips, using fpcalc. They look like this:
AQAAE9GSKVOkLEOy5PlQE0d9fId7HD-aHD_xhMeRrKORLseX44etHD8AYcAgSrEjDKFAsIGIFAJZ
AQAAE1M9RUkW1NGFH0d4HcnyJIlw4UW17HiyPMHt4B18EX2go9qJTz_eJzgBgBg4CphigUCMGCWFAcAw
AQAAAA
Now I record a sound and fingerprint it, it might look like this:
AQAAE5ISLVOkTEF-QfURpkGZHHeeIpehB3HMoRKaikbTKHvQNnlwpIdOxNHHY_IPJttlAECEI8BBAAgFAiigAA
Now Im looking at my database to find the closest match using levenshtein distance like this:
def levenshtein_distance(first, second):
"""Find the Levenshtein distance between two strings."""
if len(first) > len(second):
first, second = second, first
if len(second) == 0:
return len(first)
first_length = len(first) + 1
second_length = len(second) + 1
distance_matrix = [[0] * second_length for x in range(first_length)]
for i in range(first_length):
distance_matrix[i][0] = i
for j in range(second_length):
distance_matrix[0][j]=j
for i in xrange(1, first_length):
for j in range(1, second_length):
deletion = distance_matrix[i-1][j] + 1
insertion = distance_matrix[i][j-1] + 1
substitution = distance_matrix[i-1][j-1]
if first[i-1] != second[j-1]:
substitution += 1
distance_matrix[i][j] = min(insertion, deletion, substitution)
return distance_matrix[first_length-1][second_length-1]
Im not getting good results, as the sounds does not match well with the samples I give it.
Am I doing this correctly? Are there better fingerprinting libraries out there? Im using python or ruby..
Im trying to match a wistle to a bird call.