问题描述
我正在尝试从识别来自麦克风.py 中运行此功能:
def return_matches(hashes):
mapper = {}
for hash,offset in hashes:
mapper[hash.upper()] = offset
values = mapper.keys()
for split_values in grouper(values,1000):
# @todo move to db related files
query = """
SELECT upper(hash),song_fk,offset
FROM fingerprints
WHERE upper(hash) IN (%s)
"""
split_values=list(split_values)
query = query % ','.join('?' * len(split_values))
x = db.executeall(query,split_values)
matches_found = len(x)
if matches_found > 0:
msg = ' ** found %d hash matches (step %d/%d)'
print ((msg) % (
matches_found,len(split_values),len(values)
))
else:
msg = ' ** not matches found (step %d/%d)'
print ((msg) % (
len(split_values),len(values)
))
for hash,sid,offset in x:
# (sid,db_offset - song_sampled_offset)
yield (sid,offset - mapper[hash])
但是,它返回错误:
File "recognize-from-microphone.py",line 135,in return_matches
yield (sid,offset - mapper[hash])
numpy.core._exceptions.UFuncTypeError: ufunc
'subtract' did not contain a loop with signature
matching types (dtype('S11'),dtype('S11')) ->
dtype('S11')
我尝试将 mapper[hash] 转换为整数,但没有奏效,但我觉得我一直做错了。根据我的理解,偏移量已经是一个整数,所以我没有尝试转换它。任何帮助都会很棒!谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)