AcoustID音频指纹环境配置--Server
配置AcoustID开源项目的Server端,包括两部分内容:acoustid-server和acoustid-index。
分别参考https://bitbucket.org/acoustid/acoustid-server
https://bitbucket.org/acoustid/acoustid-index
###acoustid-server配置###
#下载源代码,安装依赖包
git clone https://bitbucket.org/acoustid/acoustid-serer.git sudo apt-get install postgresql postgresql-contrib sudo apt-get install redis-server sudo apt-get install python python-dev python-virtualenv sudo apt-get install postgresql-9.1-acoustid
#下载安装postgresql-9.1-acoustid
wget http://deb.oxygene.sk/ubuntu/dists/precise/main/binary-amd64/postgresql-9.1-acoustid_0+r27_amd64.deb dpkg -i postgresql-9.1-acoustid_0+r27_amd64.deb #不同版本的机器可以去http://deb.oxygene.sk/ubuntu/dists/trusty/main/找安装包
#配置Python虚拟环境
virtualenv e source e/bin/activate pip insatll -r requirements.txt
#配置postgresql数据库
sudo -u postgres createuser acoustid sudo -u postgres createdb -O acoustid acoustid #这里分别创建了名称为acoustid的用户,以及名称为acoustid的数据库 psql -U postgres alter user acoustid with password 'yourpassword'; #登录postgresql,修改acoustid密码
#修改配置文件
cp acoustid.conf.dist acoustid.conf vim acoustid.conf #修改配置文件为上步修改的密码,password=yourpassword
#在数据库中添加扩展应用
sudo -u postgres psql acoustid -c 'CREATE EXTENSION intarray'; sudo -u postgres psql acoustid -c 'CREATE EXTENSION pgcrypto'; sudo -u postgres psql acoustid -c 'CREATE EXTENSION acoustid';
#创建数据库的表结构
./run_psql.sh < sql/CreateTables.sql ./run_psql.sh < sql/CreatePrimaryKeys.sql ./run_psql.sh < sql/CreateFKConstraints.sql ./run_psql.sh < sql/CreateIndexes.sql
#测试运行
./run_web.sh --host=0.0.0.0
#修改源代码
vim e/lib/python2.7/site-packages/chromaprint.py #将第89行 if res!=1: 修改为if res!=0: #否则会报Fingerprinterror() #测试修改后功能未受影响
#修改源代码,指纹查询本地数据库(建立index索引后可以不必设置从数据库查询)
vim acoustid/data/fingerprint.py #修改FingerprintSearcher.search() #line 136 if not self.fast and not matches -> if self.fast and not matches
#如运行无误,可进行下一步配置
###acoustid-index配置###
#下载源代码,安装
git clone https://bitbucket.org/acoustid/acoustid-index.git cmake . make && make install
#测试运行
./fpi-server
###总的Server端环境测试###
#分别开启acoustid-server和acoustid-index服务
./run_web.sh --api ./fpi-server
#建立index索引
cd acoustid-server cp scripts/update_index.py update_index.py
vim acoustid/data/fingerprint.py #修改limit > 数据库中fingerprint的总数 python update_index.py -c acoustid.conf
#开启服务后,可以通过网页访问Server端的api接口,也就是acoustid的web-service。URL为:http://127.0.0.1:5000/api/ws/v2/lookup?client=XXX&duration=XXX&fingerprint=***
其中,http://127.0.0.1:5000/api/ws/v2/为接口前缀,之后的lookup和submit分别调用查询和提交处理函数,client、duration、fingerprint则是对应的参数。详细可以查看acoustid-server/acoustid/server.py。client对应的参数可以自行在postgresql数据库acoustid的account表中添加,duration和fingerprint可以用Chromaprint通过计算音频文件的指纹信息得到。
为了使submit提交到数据库中,还需修改acoustid-server/acoustid/api/v2/__init__.py中的SubmitHandler函数。
lookup查询的信息也可以通过修改acoustid-server/acoustid/api/v2/__init__.py中的LookupHandler函数调整。

浙公网安备 33010602011771号