我正在使用 fpcalc 从声音剪辑中获取音频指纹。它们看起来像这样:
AQAAE9GSKVOkLEOy5PlQE0d9fId7HD-aHD_xhMeRrKORLseX44etHD8AYcAgSrEjDKFAsIGIFAJZ
AQAAE1M9RUkW1NGFH0d4HcnyJIlw4UW17HiyPMHt4B18EX2go9qJTz_eJzgBgBg4CphigUCMGCWFAcAw
AQAAAA
现在我录制一个声音并对其进行指纹识别,它可能看起来像这样:
AQAAE5ISLVOkTEF-QfURpkGZHHeeIpehB3HMoRKaikbTKHvQNnlwpIdOxNHHY_IPJttlAECEI8BBAAgFAiigAA
现在我查看我的数据库以使用 levenshtein 距离找到最接近的匹配项,如下所示:
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]
我没有得到好的结果,因为声音与我给它的样本不匹配。
我这样做正确吗?那里有更好的指纹库吗?我使用python或ruby ..
我试图将哨子与鸟叫声相匹配。