diff --git a/README.md b/README.md index 9c53b41..fc9c3bd 100644 --- a/README.md +++ b/README.md @@ -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. -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 >>> from dejavu import Dejavu >>> config = { diff --git a/go.py b/go.py index 9108f4e..7472019 100755 --- a/go.py +++ b/go.py @@ -1,22 +1,29 @@ from dejavu import Dejavu -from ConfigParser import ConfigParser import warnings +import json warnings.filterwarnings("ignore") -# load config -config = ConfigParser() -config.read("dejavu.cnf") +# load config from a JSON file (or anything outputting a python dictionary) +with open("dejavu.cnf") as f: + config = json.load(f) -# create Dejavu object -dejavu = Dejavu(config) -dejavu.fingerprint("va_us_top_40/mp3", "va_us_top_40/wav", [".mp3"], 5) +# create a Dejavu instance +djv = Dejavu(config) +# 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) -#print song \ No newline at end of file + +# Or recognize audio from your microphone for 10 seconds +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")