Skip to content
Audio fingerprinting and recognition in Python
Branch: master
Clone or download
Pull request Compare This branch is 45 commits ahead of worldveil:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dejavu updates for speed and large-scale indexing Nov 8, 2018
mp3 Merging in new test suite with modifications, mp3 example files to te… Jul 3, 2014
plots Added more documentation in README about testing Jul 3, 2014
.gitignore updates for speed and large-scale indexing Nov 8, 2018
.style.yapf Change Database Backend to use SQLAlchemy instead. (#1) Jul 6, 2018
CHANGES.md updates for speed and large-scale indexing Nov 8, 2018
Dockerfile Update dockerfile order to utilize cache better. Sep 4, 2018
INSTALLATION.md
LICENSE.md refactored testing suite file to no longer depend on file naming conv… Jul 2, 2014
MANIFEST.in
Pipfile
Pipfile.lock Change python version to major/minor Aug 27, 2018
README.md updates for speed and large-scale indexing Nov 8, 2018
dejavu.py Fixing version so it is sourced correctly from the version.py file Sep 5, 2018
docker-compose.development.yml Add docker compose and Dockerfiles for testing Aug 27, 2018
docker-compose.yml Add docker compose and Dockerfiles for testing Aug 27, 2018
example.py Use logging module inside library Jul 13, 2018
requirements.txt Removed pkg-resources line from requirements.txt Jul 19, 2018
run_tests.py Make matplotlib headless - needs to be call before everything. Aug 27, 2018
setup.py Fixing version so it is sourced correctly from the version.py file Sep 5, 2018
test_dejavu.sh updates for speed and large-scale indexing Nov 8, 2018

README.md

dejavu

Purpose

This fork attempts to:

  • [✔️] Fix bugs (fixes critical numpy one).
  • [✔️] Use SQLAlchemy to support PostgreSQL, SQLite3 DBs as well.
  • [✔️] Use Pipenv to allow db credentials via .env file
  • [✔️] Support both Python3 and Python2.
  • [WIP] Use the logging module so as to not litter any user's application with prints.
  • [✔️] Reformat code using YAPF (Facebook)

Usage

  1. Install directly from this repo:
pip install -e git+https://github.com/bcollazo/dejavu@v1.2#egg=PyDejavu
  1. Import and use:
from dejavu import Dejavu
from dejavu.recognize import FileRecognizer

djv = Dejavu(dburl='sqlite://')
djv.fingerprint_directory('~/Music')
song = djv.recognize(FileRecognizer, 'mp3/Dura--Daddy-Yankee.mp3')
print(song)
  1. Can also be used as a CLI tool:
export DATABASE_URL=mysql+mysqlconnector://bryan:password@localhost/dejavu
python dejavu.py --fingerprint ~/Music mp3 --limit 30
python dejavu.py --recognize mic 10
python dejavu.py --recognize file sometrack.mp3

You can keep the database url saved in an .env file and use pipenv. As well as specify it via the --dburl command line argument.

NOTE Some incompatibility around byte encoding is present with this connector pair for some database versions (e.g. MariaDb). Consider using mysql+pymysql instead of mysql+mysqlconnector with a simple fingerprint to check for this error.

Migrating from worldveil/dejavu

If you already have a live database that used to follow worldveil/dejavu database structure, you'll have to migrate your database by renaming:

  • song_id to id
  • song_name to name

in the songs table.

Testing

We have included a docker-compose.yml and Dockerfile that allows 'headless' testing.

Build container

You can choose the Python version you wish to build with by setting:

export PYTHON_VERION=3.6.6

Or update the Pipfile with the version you want and use:

export PYTHON_VERSION=$(cat Pipfile | awk '/python_version/ {print $3}' | tr -d '"')

Then run the build:

docker-compose build

This creates a dejavu container.

Test with docker-compose

Once the container is built, you can run your tests:

docker-compose run dejavu pipenv run run_tests

This will run the script called run_tests in the Pipfile

You can get a shell with:

docker-compose run dejavu /bin/bash

You can then run tests inside the container with either pipenv run run_tests or bash test_dejavu.sh

You can change the default command the container/service will run by changing the CMD in the Dockerfile or command in the docker-compose.yml file. Currently they are set to tail -f /dev/null which basically keeps a process running in the container without doing anything.

You may want to set these to pipenv run run_tests for testing. See Docker or docker-compose

You can’t perform that action at this time.