Giter Site home page Giter Site logo

dejavu's Introduction

dejavu

Purpose

This fork attempts to:

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

Usage

  1. Install directly from this repo:
pip install -e git+https://github.com/bcollazo/[email protected]#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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.