dejavu
最近帮朋友试验个声纹识别工具dejavu,费了不少劲,网络上也没搜到有效的解决办法,所以把遇到的坑列出来,希望能帮到你。
源代码参考github
First, 下载源代码后创建了一个虚拟环境,使用的是 python2.7.10 on macOS
Second, 安装依赖库.
brew install portaudio
brew install ffmpeg
pip install -r requirement.txt
Then, 修改一些必要的代码:
- dejavu/database_sql.py 第5行位置需要安装mysql-python,而我尝试很久没有成功,所以替换为pymysql
import pymysql as mysql
from pymysql.cursors import DictCursor
- dejavu/fingerprint.py 第3行位置倒入matplotlib部分,提示Python is not installed as a framework.
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
- dejavu/init.py 第86行位置,之前提示'numpy.int64' object has no attribute 'translate'
else:
def _convert_hashes(hashes=None):
new_hashes = set()
if hashes:
for i in hashes:
new_i =(i[0], int(i[1]))
new_hashes.add(new_i)
return new_hashes
sid = self.db.insert_song(song_name, file_hash)
hashes = _convert_hashes(hashes)
self.db.insert_hashes(sid, hashes)
self.db.set_song_fingerprinted(sid)
self.get_fingerprinted_songs()
- 创建本地数据库
$ mysql -u root -p
Enter password: **********
mysql> CREATE DATABASE IF NOT EXISTS dejavu;
-
修改数据库配置 dejavu/dejavu.cnf.SAMPLE文件
-
运行example.py测试
屏幕快照 2018-11-13 16.46.40.png
网友评论