Updated go.py

Added clarification that the configuration is now an ordinary python
dictionary to the README.
This commit is contained in:
Wessie 2013-12-19 17:15:11 +01:00
parent 2f19fcaa51
commit ec823f56e4
2 changed files with 23 additions and 15 deletions

View file

@ -36,7 +36,8 @@ Now you're ready to start fingerprinting your audio collection!
Let's say we want to fingerprint all of July 2013's VA US Top 40 hits. Let's say we want to fingerprint all of July 2013's VA US Top 40 hits.
Start by creating a Dejavu object. Start by creating a Dejavu object with your configurations settings (Dejavu takes an ordinary Python dictionary for the settings).
```python ```python
>>> from dejavu import Dejavu >>> from dejavu import Dejavu
>>> config = { >>> config = {

35
go.py
View file

@ -1,22 +1,29 @@
from dejavu import Dejavu from dejavu import Dejavu
from ConfigParser import ConfigParser
import warnings import warnings
import json
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
# load config # load config from a JSON file (or anything outputting a python dictionary)
config = ConfigParser() with open("dejavu.cnf") as f:
config.read("dejavu.cnf") config = json.load(f)
# create Dejavu object # create a Dejavu instance
dejavu = Dejavu(config) djv = Dejavu(config)
dejavu.fingerprint("va_us_top_40/mp3", "va_us_top_40/wav", [".mp3"], 5) # Fingerprint all the mp3's in the directory we give it
djv.fingerprint_directory("va_us_top_40/mp3", [".mp3"], 5)
# recognize microphone audio
from dejavu.recognize import Recognizer
recognizer = Recognizer(dejavu.fingerprinter, config)
song = recognizer.read("va_us_top_40/wav/17_-_#Beautiful_-_Mariah_Carey_ft.wav") # Recognize audio from a file
from dejavu.recognize import FileRecognizer
song = djv.recognize(FileRecognizer, "va_us_top_40/wav/17_-_#Beautiful_-_Mariah_Carey_ft.wav")
# recognize song playing over microphone for 10 seconds
#song = recognizer.listen(seconds=1, verbose=True) # Or recognize audio from your microphone for 10 seconds
#print song from dejavu.recognize import MicrophoneRecognizer
song = djv.recognize(MicrophoneRecognizer, seconds=10)
# Or use a recognizer without the shortcut, in anyway you would like
from dejavu.recognize import FileRecognizer
recognizer = FileRecognizer(djv)
song = recognizer.recognize_file("va_us_top_40/wav/17_-_#Beautiful_-_Mariah_Carey_ft.wav")