mirror of
https://github.com/correl/dejavu.git
synced 2024-11-27 11:09:51 +00:00
Refactor and update documentation for installation on Fedora 20+
This commit is contained in:
parent
2972dce6eb
commit
4aabea7814
4 changed files with 85 additions and 62 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):
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ class Dejavu(object):
|
||||||
# if we should limit seconds fingerprinted,
|
# if we should limit seconds fingerprinted,
|
||||||
# None|-1 means use entire track
|
# None|-1 means use entire track
|
||||||
self.limit = self.config.get("fingerprint_limit", None)
|
self.limit = self.config.get("fingerprint_limit", None)
|
||||||
if self.limit == -1: # for JSON compatibility
|
if self.limit == -1: # for JSON compatibility
|
||||||
self.limit = None
|
self.limit = None
|
||||||
self.get_fingerprinted_songs()
|
self.get_fingerprinted_songs()
|
||||||
|
|
||||||
|
@ -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,13 +95,12 @@ 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
|
|
||||||
if song_name in self.songnames_set:
|
if song_name in self.songnames_set:
|
||||||
print "%s already fingerprinted, continuing..." % song_name
|
print "%s already fingerprinted, continuing..." % song_name
|
||||||
else:
|
else:
|
||||||
song_name, hashes = _fingerprint_worker(filepath,
|
song_name, hashes = _fingerprint_worker(filepath,
|
||||||
self.limit,
|
self.limit,
|
||||||
song_name=song_name)
|
song_name=song_name)
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue