Example #1
0
        def testFileRecognizer(self):
            """Recognize audio from a file"""
            recognizer = FileRecognizer(self.djv)
            result = recognizer.recognize_file(self.fileName)

            self.assertEqual(self.song_name, result['song_name'])
            print "(w/o shortcut) we recognized: %s\n" % result['song_name']
Example #2
0
def check_dejavu(path):

    dburl = 'sqlite:///new.db'
    djv = Dejavu(dburl=dburl)
    recognizer = FileRecognizer(djv)
    song = recognizer.recognize_file(path)
    if song['confidence'] < DEJAVU_THRESHOLD:
        return ("Not found", False)
    return (song['song_id'], True)
 def nonblocking_recognize_file_path(self, file_path, ws):
     r = FileRecognizer(self.djv)
     frames, r.Fs = decoder.read_chunks(file_path, r.dejavu.limit)
     for i, val in enumerate(frames):
         match = r._recognize(*val)
         if match is not None:
             match['segment_id'] = i
             match['start_time'] = i * ChunksTime / 1000
             ws.write_message(json.dumps(match))
         else:
             ws.write_message(json.dumps({}))
Example #4
0
def upload():
    subprocess.call("php ~/root/clunkr/static/upload.php") # runs the php upload script
    directory_list = os.listdir("~/root/recordings") # grabs the files from the recording directory
    file_name = directory_list.pop # pulls filename of the most recent recording from recordings
    recognizer = FileRecognizer(djv)
    match = ""
    with open("~/root/recordings" + file_name) as f: # opens file as f
        match = recognizer.recognize_file(f) # recognizer returns filename
    flash("Uploading and looking for a match.", "info")
    #os.popen("rm -f ~/root/recordings")  deletes files after match is made
    return render_template("result.html",
                          match=match
                          )
Example #5
0
def upload():
    subprocess.call(
        "php ~/root/clunkr/static/upload.php")  # runs the php upload script
    directory_list = os.listdir(
        "~/root/recordings")  # grabs the files from the recording directory
    file_name = directory_list.pop  # pulls filename of the most recent recording from recordings
    recognizer = FileRecognizer(djv)
    match = ""
    with open("~/root/recordings" + file_name) as f:  # opens file as f
        match = recognizer.recognize_file(f)  # recognizer returns filename
    flash("Uploading and looking for a match.", "info")
    #os.popen("rm -f ~/root/recordings")  deletes files after match is made
    return render_template("result.html", match=match)
Example #6
0
def file_recognise(file):
    djv = Dejavu(config)
    if file.endswith('.mp3'):
        print('checking file...', file)
        recognizer = FileRecognizer(djv)
        song = recognizer.recognize_file("file")
        print "No shortcut, we recognized: %s\n" % song
    elif file.endswith('.m4a'):
        print('checking file...', file)
        recognizer = FileRecognizer(djv)
        song = recognizer.recognize_file("file")
        print
        "No shortcut, we recognized: %s\n" % song
Example #7
0
########NEW FILE########
__FILENAME__ = example
from dejavu import Dejavu
import warnings
import json
warnings.filterwarnings("ignore")

# load config from a JSON file (or anything outputting a python dictionary)
with open("dejavu.cnf") as f:
    config = json.load(f)

# create a Dejavu instance
djv = Dejavu(config)
# Fingerprint all the mp3's in the directory we give it
djv.fingerprint_directory("mp3", [".mp3"])

# Recognize audio from a file
from dejavu.recognize import FileRecognizer
song = djv.recognize(FileRecognizer, "mp3/beware.mp3")

# Or recognize audio from your microphone for 10 seconds
from dejavu.recognize import MicrophoneRecognizer
song = djv.recognize(MicrophoneRecognizer, seconds=2)

# Or use a recognizer without the shortcut, in anyway you would like
from dejavu.recognize import FileRecognizer
recognizer = FileRecognizer(djv)
song = recognizer.recognize_file("mp3/sail.mp3")
########NEW FILE########
Example #8
0
with open("dejavu.cnf.SAMPLE") as f:
    config = json.load(f)

if __name__ == '__main__':

    # create a Dejavu instance
    djv = Dejavu(config)

    # Fingerprint all the mp3's in the directory we give it
    djv.fingerprint_directory("mp3", [".mp3"])

    # Recognize audio from a file
    song = djv.recognize(FileRecognizer,
                         "mp3/Sean-Fournier--Falling-For-You.mp3")
    print("From file we recognized: {}\n", song)

    # Or recognize audio from your microphone for `secs` seconds
    secs = 5
    song = djv.recognize(MicrophoneRecognizer, seconds=secs)
    if song is None:
        print(
            "Nothing recognized -- did you play the song out loud so your mic could hear it? :)"
        )
    else:
        print("From mic with {} seconds we recognized: {}\n", secs, song)

    # Or use a recognizer without the shortcut, in anyway you would like
    recognizer = FileRecognizer(djv)
    song = recognizer.recognize_file(
        "mp3/Josh-Woodward--I-Want-To-Destroy-Something-Beautiful.mp3")
    print("No shortcut, we recognized: {}\n", song)
Example #9
0
}

# load config from a JSON file (or anything outputting a python dictionary)
#with open("dejavu.cnf.SAMPLE") as f:
#    config = json.load(f)

if __name__ == '__main__':

	# create a Dejavu instance
	djv = Dejavu(config)

	# Fingerprint all the mp3's in the directory we give it
	djv.fingerprint_directory("mp3", [".mp3"])

	# Recognize audio from a file
	song = djv.recognize(FileRecognizer, "mp3/Sean-Fournier--Falling-For-You.mp3")
	print "From file we recognized: %s\n" % song

	# Or recognize audio from your microphone for `secs` seconds
	secs = 5
	song = djv.recognize(MicrophoneRecognizer, seconds=secs)
	if song is None:
		print "Nothing recognized -- did you play the song out loud so your mic could hear it? :)"
	else:
		print "From mic with %d seconds we recognized: %s\n" % (secs, song)

	# Or use a recognizer without the shortcut, in anyway you would like
	recognizer = FileRecognizer(djv)
	song = recognizer.recognize_file("mp3/Josh-Woodward--I-Want-To-Destroy-Something-Beautiful.mp3")
	print "No shortcut, we recognized: %s\n" % song
Example #10
0
from dejavu import Dejavu
import warnings
import json
warnings.filterwarnings("ignore")

# load config from a JSON file (or anything outputting a python dictionary)
with open("dejavu.cnf") as f:
    config = json.load(f)

# create a Dejavu instance
djv = Dejavu(config)
# Fingerprint all the mp3's in the directory we give it
djv.fingerprint_directory("mp3", [".mp3"])

# Recognize audio from a file
from dejavu.recognize import FileRecognizer
song = djv.recognize(FileRecognizer, "mp3/beware.mp3")

# Or recognize audio from your microphone for 10 seconds
from dejavu.recognize import MicrophoneRecognizer
song = djv.recognize(MicrophoneRecognizer, seconds=2)

# Or use a recognizer without the shortcut, in anyway you would like
from dejavu.recognize import FileRecognizer
recognizer = FileRecognizer(djv)
song = recognizer.recognize_file("mp3/sail.mp3")
Example #11
0
from dejavu import Dejavu
from dejavu.recognize import FileRecognizer, MicrophoneRecognizer

# load config from a JSON file (or anything outputting a python dictionary)
with open("dejavu.cnf.SAMPLE") as f:
    config = json.load(f)

if __name__ == '__main__':

    # create a Dejavu instance
    djv = Dejavu(config)

    # Fingerprint all the mp3's in the directory we give it
    #djv.fingerprint_directory("mp3", [".mp3"])

    # # Recognize audio from a file
    # song = djv.recognize(FileRecognizer, "mp3/Sean-Fournier--Falling-For-You.mp3")
    # print("From file we recognized: %s\n" % song)
    #
    # # Or recognize audio from your microphone for `secs` seconds
    # secs = 5
    # song = djv.recognize(MicrophoneRecognizer, seconds=secs)
    # if song is None:
    # 	print("Nothing recognized -- did you play the song out loud so your mic could hear it? :)")
    # else:
    # 	print("From mic with %d seconds we recognized: %s\n" % (secs, song))

    # Or use a recognizer without the shortcut, in anyway you would like
    recognizer = FileRecognizer(djv)
    song = recognizer.recognize_file("mp3/test_josh.mp3")
    print("No shortcut, we recognized: %s\n" % song)
Example #12
0
warnings.filterwarnings("ignore")

if __name__ == '__main__':
    loggerer(True)
    dburl = os.getenv('DATABASE_URL', 'sqlite:///test.db')
    logging.info(dburl)
    djv = Dejavu(dburl=dburl)

    # Fingerprint all the mp3's in the directory we give it
    djv.fingerprint_directory("mp3", [".mp3", ".wav"], 3)
    # Recognize audio from a file
    song = djv.recognize(FileRecognizer,
                         "mp3/Choc--Eigenvalue-Subspace-Decomposition.mp3")
    print("From file we recognized: %s\n" % song)

    # Or recognize audio from your microphone for `secs` seconds
    #secs = 5
    #song = djv.recognize(MicrophoneRecognizer, seconds=secs)
    #if song is None:
    #    print(
    #        "Nothing recognized -- did you play the song out loud so your mic could hear it? :)"
    #    )
    #else:
    #    print("From mic with %d seconds we recognized: %s\n" % (secs, song))

    # Or use a recognizer without the shortcut, in anyway you would like
    recognizer = FileRecognizer(djv)
    song = recognizer.recognize_file(
        "I:\\[SAMPLES]\\[DRUM]\\!1 Lonly1nes\\Slightoven 808.wav")
    print("No shortcut, we recognized: %s\n" % song)
Example #13
0
         "user": "******",
         "passwd": "vahbiav", 
         "db": "comm_new",
		 
     }
 }
djv = Dejavu(config)

#djv.fingerprint_directory("/home/vaibhav/audio/commercials - mp3", [".mp3"], 4)
#print djv.db.get_num_fingerprints()

#song = djv.recognize(FileRecognizer, "/media/sf_C_DRIVE/Users/vsahu/Desktop/audio/train/3.mp3",limit=10)
#print "From file we recognized: %s\n" % song


recognizer = FileRecognizer(djv)
filename = "/home/vaibhav/audio/radio break - mp3/tafe.mp3"
#song = recognizer.recognize_file(filename = filename ,start = 30,limit=40)
#limit=5
for start in range(0,670,30):
#start =0
    s = time.time()
    song = recognizer.recognize_file(filename = filename ,start = start,limit=start+30)
#    #song = recognizer.recognize_file(filename = filename)
#    if song["confidence"] >=1000:
    if song["confidence"] > 100:
        print "song name: %s\n" % song["song_name"]
        print "confidence: %s\n" % song["confidence"]
    t = time.time() - s
    print t
        
Example #14
0
import warnings
import json

warnings.filterwarnings("ignore")

from dejavu import Dejavu
from dejavu.recognize import FileRecognizer, MicrophoneRecognizer

# load config from a JSON file (or anything outputting a python dictionary)
with open("dejavu.cnf.SAMPLE") as f:
    config = json.load(f)

if __name__ == '__main__':

    djv = Dejavu(config)

    recognizer = FileRecognizer(djv)
    song = recognizer.recognize_file("RAW/ironManRaw.WAV")
    print "No shortcut, we recognized: %s\n" % song

    song = recognizer.recognize_file("RAW/IronMan_420-425secs.wav")
    print "No shortcut, we recognized: %s\n" % song

    song = recognizer.recognize_file("RAW/IronMan_420-425secs.mp3")
    print "No shortcut, we recognized: %s\n" % song