mirror of
https://github.com/correl/dejavu.git
synced 2024-11-23 19:19:53 +00:00
Merge branch 'next_version'
This commit is contained in:
commit
6c1ef735cd
6 changed files with 109 additions and 70 deletions
|
@ -1,31 +0,0 @@
|
||||||
# Dependencies required by dejavu
|
|
||||||
|
|
||||||
* [`pyaudio`](http://people.csail.mit.edu/hubert/pyaudio/)
|
|
||||||
* [`ffmpeg`](https://github.com/FFmpeg/FFmpeg)
|
|
||||||
* [`pydub`](http://pydub.com/)
|
|
||||||
* [`numpy`](http://www.numpy.org/)
|
|
||||||
* [`scipy`](http://www.scipy.org/)
|
|
||||||
* [`matplotlib`](http://matplotlib.org/)
|
|
||||||
* [`MySQLdb`](http://mysql-python.sourceforge.net/MySQLdb.html)
|
|
||||||
|
|
||||||
## Dependency installation for Mac OS X
|
|
||||||
|
|
||||||
Tested on OS X Mavericks. An option is to install [Homebrew](http://brew.sh) and do the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
brew install portaudio
|
|
||||||
brew install ffmpeg
|
|
||||||
|
|
||||||
sudo easy_install pyaudio
|
|
||||||
sudo easy_install pydub
|
|
||||||
sudo easy_install numpy
|
|
||||||
sudo easy_install scipy
|
|
||||||
sudo easy_install matplotlib
|
|
||||||
sudo easy_install pip
|
|
||||||
|
|
||||||
sudo pip install MySQL-python
|
|
||||||
|
|
||||||
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
|
|
||||||
```
|
|
||||||
|
|
||||||
However installing `portaudio` and/or `ffmpeg` from source is also doable.
|
|
63
INSTALLATION.md
Normal file
63
INSTALLATION.md
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# Installation of dejavu
|
||||||
|
|
||||||
|
So far dejavu has only been tested on Unix systems.
|
||||||
|
|
||||||
|
* [`pyaudio`](http://people.csail.mit.edu/hubert/pyaudio/) for grabbing audio from microphone
|
||||||
|
* [`ffmpeg`](https://github.com/FFmpeg/FFmpeg) for converting audio files to .wav format
|
||||||
|
* [`pydub`](http://pydub.com/), a Python `ffmpeg` wrapper
|
||||||
|
* [`numpy`](http://www.numpy.org/) for taking the FFT of audio signals
|
||||||
|
* [`scipy`](http://www.scipy.org/), used in peak finding algorithms
|
||||||
|
* [`matplotlib`](http://matplotlib.org/), used for spectrograms and plotting
|
||||||
|
* [`MySQLdb`](http://mysql-python.sourceforge.net/MySQLdb.html) for interfacing with MySQL databases
|
||||||
|
|
||||||
|
For installing `ffmpeg` on Mac OS X, I highly recommend [this post](http://jungels.net/articles/ffmpeg-howto.html).
|
||||||
|
|
||||||
|
## Fedora 20+
|
||||||
|
|
||||||
|
### Dependency installation for Mac OS X
|
||||||
|
|
||||||
|
Install the dependencies
|
||||||
|
|
||||||
|
sudo yum install numpy scipy python-matplotlib ffmpeg portaudio-devel
|
||||||
|
pip install PyAudio
|
||||||
|
pip install pydub
|
||||||
|
|
||||||
|
Now setup virtualenv ([howto?](http://www.pythoncentral.io/how-to-install-virtualenv-python/))
|
||||||
|
|
||||||
|
pip install virtualenv
|
||||||
|
virtualenv --system-site-packages env_with_system
|
||||||
|
|
||||||
|
Install from PyPI
|
||||||
|
|
||||||
|
source env_with_system/bin/activate
|
||||||
|
pip install PyDejavu
|
||||||
|
|
||||||
|
|
||||||
|
You can also install the latest code from GitHub:
|
||||||
|
|
||||||
|
source env_with_system/bin/activate
|
||||||
|
pip install https://github.com/tuxdna/dejavu/zipball/master
|
||||||
|
|
||||||
|
## Max OS X
|
||||||
|
|
||||||
|
### Dependency installation for Mac OS X
|
||||||
|
|
||||||
|
Tested on OS X Mavericks. An option is to install [Homebrew](http://brew.sh) and do the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install portaudio
|
||||||
|
brew install ffmpeg
|
||||||
|
|
||||||
|
sudo easy_install pyaudio
|
||||||
|
sudo easy_install pydub
|
||||||
|
sudo easy_install numpy
|
||||||
|
sudo easy_install scipy
|
||||||
|
sudo easy_install matplotlib
|
||||||
|
sudo easy_install pip
|
||||||
|
|
||||||
|
sudo pip install MySQL-python
|
||||||
|
|
||||||
|
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
|
||||||
|
```
|
||||||
|
|
||||||
|
However installing `portaudio` and/or `ffmpeg` from source is also doable.
|
16
README.md
16
README.md
|
@ -6,19 +6,9 @@ Audio fingerprinting and recognition algorithm implemented in Python, see the ex
|
||||||
|
|
||||||
Dejavu can memorize audio by listening to it once and fingerprinting it. Then by playing a song and recording microphone input, Dejavu attempts to match the audio against the fingerprints held in the database, returning the song being played.
|
Dejavu can memorize audio by listening to it once and fingerprinting it. Then by playing a song and recording microphone input, Dejavu attempts to match the audio against the fingerprints held in the database, returning the song being played.
|
||||||
|
|
||||||
## Dependencies:
|
## Installation and Dependencies:
|
||||||
|
|
||||||
I've only tested this on Unix systems.
|
Read [INSTALLATION.md](INSTALLATION.md)
|
||||||
|
|
||||||
* [`pyaudio`](http://people.csail.mit.edu/hubert/pyaudio/) for grabbing audio from microphone
|
|
||||||
* [`ffmpeg`](https://github.com/FFmpeg/FFmpeg) for converting audio files to .wav format
|
|
||||||
* [`pydub`](http://pydub.com/), a Python `ffmpeg` wrapper
|
|
||||||
* [`numpy`](http://www.numpy.org/) for taking the FFT of audio signals
|
|
||||||
* [`scipy`](http://www.scipy.org/), used in peak finding algorithms
|
|
||||||
* [`matplotlib`](http://matplotlib.org/), used for spectrograms and plotting
|
|
||||||
* [`MySQLdb`](http://mysql-python.sourceforge.net/MySQLdb.html) for interfacing with MySQL databases
|
|
||||||
|
|
||||||
For installing `ffmpeg` on Mac OS X, I highly recommend [this post](http://jungels.net/articles/ffmpeg-howto.html).
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
@ -148,7 +138,7 @@ and with the command line script, you specify the number of seconds to listen:
|
||||||
$ python dejavu.py --recognize mic 10
|
$ python dejavu.py --recognize mic 10
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing (New!)
|
## Testing
|
||||||
|
|
||||||
Testing out different parameterizations of the fingerprinting algorithm is often useful as the corpus becomes larger and larger, and inevitable tradeoffs between speed and accuracy come into play.
|
Testing out different parameterizations of the fingerprinting algorithm is often useful as the corpus becomes larger and larger, and inevitable tradeoffs between speed and accuracy come into play.
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ import dejavu.decoder as decoder
|
||||||
import fingerprint
|
import fingerprint
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Dejavu(object):
|
class Dejavu(object):
|
||||||
|
|
||||||
|
@ -79,9 +82,7 @@ class Dejavu(object):
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
print("Failed fingerprinting")
|
print("Failed fingerprinting")
|
||||||
|
|
||||||
# Print traceback because we can't reraise it here
|
# Print traceback because we can't reraise it here
|
||||||
import traceback, sys
|
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
else:
|
else:
|
||||||
sid = self.db.insert_song(song_name)
|
sid = self.db.insert_song(song_name)
|
||||||
|
@ -94,7 +95,6 @@ class Dejavu(object):
|
||||||
pool.join()
|
pool.join()
|
||||||
|
|
||||||
def fingerprint_file(self, filepath, song_name=None):
|
def fingerprint_file(self, filepath, song_name=None):
|
||||||
|
|
||||||
songname = decoder.path_to_songname(filepath)
|
songname = decoder.path_to_songname(filepath)
|
||||||
song_name = song_name or songname
|
song_name = song_name or songname
|
||||||
# don't refingerprint already fingerprinted files
|
# don't refingerprint already fingerprinted files
|
||||||
|
@ -129,9 +129,9 @@ class Dejavu(object):
|
||||||
song_id = -1
|
song_id = -1
|
||||||
for tup in matches:
|
for tup in matches:
|
||||||
sid, diff = tup
|
sid, diff = tup
|
||||||
if not diff in diff_counter:
|
if diff not in diff_counter:
|
||||||
diff_counter[diff] = {}
|
diff_counter[diff] = {}
|
||||||
if not sid in diff_counter[diff]:
|
if sid not in diff_counter[diff]:
|
||||||
diff_counter[diff][sid] = 0
|
diff_counter[diff][sid] = 0
|
||||||
diff_counter[diff][sid] += 1
|
diff_counter[diff][sid] += 1
|
||||||
|
|
||||||
|
@ -149,15 +149,16 @@ class Dejavu(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# return match info
|
# return match info
|
||||||
nseconds = round(float(largest) / fingerprint.DEFAULT_FS * \
|
nseconds = round(float(largest) / fingerprint.DEFAULT_FS *
|
||||||
fingerprint.DEFAULT_WINDOW_SIZE * \
|
fingerprint.DEFAULT_WINDOW_SIZE *
|
||||||
fingerprint.DEFAULT_OVERLAP_RATIO, 5)
|
fingerprint.DEFAULT_OVERLAP_RATIO, 5)
|
||||||
song = {
|
song = {
|
||||||
Dejavu.SONG_ID : song_id,
|
Dejavu.SONG_ID: song_id,
|
||||||
Dejavu.SONG_NAME : songname,
|
Dejavu.SONG_NAME: songname,
|
||||||
Dejavu.CONFIDENCE : largest_count,
|
Dejavu.CONFIDENCE: largest_count,
|
||||||
Dejavu.OFFSET : largest,
|
Dejavu.OFFSET: largest,
|
||||||
Dejavu.OFFSET_SECS : nseconds }
|
Dejavu.OFFSET_SECS: nseconds
|
||||||
|
}
|
||||||
|
|
||||||
return song
|
return song
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
### BEGIN ###
|
### BEGIN ###
|
||||||
pydub==0.9.4
|
pydub==0.9.4
|
||||||
PyAudio==0.2.8
|
PyAudio>=0.2.7
|
||||||
numpy==1.8.2
|
numpy==1.8.2
|
||||||
scipy==0.12.1
|
scipy==0.12.1
|
||||||
matplotlib==1.3.1
|
matplotlib==1.3.1
|
||||||
|
|
30
setup.py
30
setup.py
|
@ -15,9 +15,22 @@ def parse_requirements(requirements):
|
||||||
return reqs
|
return reqs
|
||||||
|
|
||||||
PACKAGE_NAME = "PyDejavu"
|
PACKAGE_NAME = "PyDejavu"
|
||||||
PACKAGE_VERSION = "0.1.1"
|
PACKAGE_VERSION = "0.1.2"
|
||||||
SUMMARY = 'Dejavu Audio Fingerprinting'
|
SUMMARY = 'Dejavu: Audio Fingerprinting in Python'
|
||||||
DESCRIPTION = """Dejavu Audio Fingerprinting"""
|
DESCRIPTION = """
|
||||||
|
Audio fingerprinting and recognition algorithm implemented in Python
|
||||||
|
|
||||||
|
See the explanation here:
|
||||||
|
|
||||||
|
`http://willdrevo.com/fingerprinting-and-audio-recognition-with-python/`__
|
||||||
|
|
||||||
|
Dejavu can memorize recorded audio by listening to it once and fingerprinting
|
||||||
|
it. Then by playing a song and recording microphone input or on disk file,
|
||||||
|
Dejavu attempts to match the audio against the fingerprints held in the
|
||||||
|
database, returning the song or recording being played.
|
||||||
|
|
||||||
|
__ http://willdrevo.com/fingerprinting-and-audio-recognition-with-python/
|
||||||
|
"""
|
||||||
REQUIREMENTS = parse_requirements("requirements.txt")
|
REQUIREMENTS = parse_requirements("requirements.txt")
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
@ -25,20 +38,23 @@ setup(
|
||||||
version=PACKAGE_VERSION,
|
version=PACKAGE_VERSION,
|
||||||
description=SUMMARY,
|
description=SUMMARY,
|
||||||
long_description=DESCRIPTION,
|
long_description=DESCRIPTION,
|
||||||
author='worldveil',
|
author='Will Drevo',
|
||||||
author_email='will.drevo@gmail.com',
|
author_email='will.drevo@gmail.com',
|
||||||
|
maintainer="Saleem Ansari",
|
||||||
|
maintainer_email="tuxdna@gmail.com",
|
||||||
url='http://github.com/tuxdna/dejavu',
|
url='http://github.com/tuxdna/dejavu',
|
||||||
license='Apache 2.0',
|
license='MIT License',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
platforms=['Any'],
|
platforms=['Unix'],
|
||||||
install_requires=REQUIREMENTS,
|
install_requires=REQUIREMENTS,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Environment :: Console',
|
'Environment :: Console',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
],
|
],
|
||||||
|
keywords="python, audio, fingerprinting, music, numpy, landmark",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue