mirror of
https://github.com/correl/dejavu.git
synced 2024-11-23 11:09:52 +00:00
Updated go.py
Added clarification that the configuration is now an ordinary python dictionary to the README.
This commit is contained in:
parent
2f19fcaa51
commit
ec823f56e4
2 changed files with 23 additions and 15 deletions
|
@ -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 = {
|
||||
|
|
35
go.py
35
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
|
||||
|
||||
# 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")
|
||||
|
|
Loading…
Reference in a new issue