当前位置: 首页>>代码示例>>Python>>正文


Python Dejavu.fingerprint_file方法代码示例

本文整理汇总了Python中dejavu.Dejavu.fingerprint_file方法的典型用法代码示例。如果您正苦于以下问题:Python Dejavu.fingerprint_file方法的具体用法?Python Dejavu.fingerprint_file怎么用?Python Dejavu.fingerprint_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dejavu.Dejavu的用法示例。


在下文中一共展示了Dejavu.fingerprint_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
def main():
    # Set up our commang line arguments
    parser = argparse.ArgumentParser(description="Take in a folder of video and/or audio files and find the alignment"
                                                 "of them all.")
    parser.add_argument("folder",type=str,help="The folder containing your audio and video files, relative to the current directory.")
    args = parser.parse_args()

    # Our DB settings
    config = {
        "database": {
            "host": "127.0.0.1",
            "user": "root",
            "passwd": "root",
            "db": "dejavu"
        }
    }


    # Get the files in our folder
    dir = os.path.expanduser(args.folder)
    files = os.listdir(dir)


    # Set up our dejavu instance
    djv = Dejavu(config)


    # Generate our corpus name - we'll add this functionality later.
    corpus = dir.replace(" ","")
    corpus = corpus.lower()

    # For now, let's just empty the DB before the experiment
    djv.db.empty()

    # Iterate through the files
    for filename in files:
        full_path = os.path.join(dir,filename)

        # For now we'll assume all the files are valid audio or video
        if (os.path.isfile(full_path)):

            print "Attempting to match {0}...".format(filename)

            # Try to match the song to the existing database
            songs = djv.recognize(FileRecognizer, full_path)

            if songs:
                for song in songs:
                    print song
            else:
                print "No matches found."

            print "Adding {0} to database...".format(filename)

            # Now let's add this song to the DB
            djv.fingerprint_file(full_path)

            print djv.db.get_num_fingerprints()
开发者ID:markkohdev,项目名称:AudioStitch,代码行数:60,代码来源:Align_Folder.py

示例2: Lilo

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
class Lilo():
    """
    The class for JamJar which will be used to identify video matches and add fingerprints to the database
    """

    def __init__(self, config, filename, video_id):
        """
        usage:
            fingerprinter = Lilo('/path/to/video/file','unique_video_id')
        """
        self.djv = Dejavu(config)
        self.filename = filename
        self.video_id = video_id

        # cache these after first fingerprint
        self.hashes = None

    def recognize_track(self):
        # Try to match the song to the existing database
        hashes, songs = self.djv.recognize(FileRecognizer, self.filename)

        self.hashes = hashes

        return songs

    def fingerprint_song(self):
        # Now let's add this song to the DB
        data = self.djv.fingerprint_file(self.filename, self.video_id, cached_hashes=self.hashes)
        return data

    def check_if_fingerprinted(self):
        video_hash = unique_hash(self.filename)
        # Set self.djv.songhashes_set
        fingerprinted_video_hashes = self.djv.get_fingerprinted_songs()
        return video_hash in self.djv.songhashes_set
开发者ID:projectjamjar,项目名称:lilo,代码行数:37,代码来源:__init__.py

示例3: DejavuPlainDBTestCases

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
class DejavuPlainDBTestCases(unittest.TestCase):
    def setUp(self):
        self.djv = Dejavu(config_plain)

    def tearDown(self):
        self.djv.db.empty()
        del self.djv

    def test_fingerprint_1_file(self):
        self.djv.fingerprint_file("tests/test1.mp3")
        # should be the only fingerprinted file
        self.assertEqual(1, self.djv.db.get_num_songs())

        self.assertEqual(5279, self.djv.db.get_num_fingerprints())

    def test_fingerprint_directory(self):
        list_dir = [f for f in os.listdir("tests") if f[-4:] == ".mp3"]
        self.djv.fingerprint_directory("tests", [".mp3"])
        self.assertEqual(len(list_dir), self.djv.db.get_num_songs())

    def test_fingerprint_1_file_10secs(self):
        self.djv.limit = 10
        self.djv.fingerprint_file("tests/test1.mp3")
        # should be the only fingerprinted file
        self.assertEqual(1, self.djv.db.get_num_songs())
        # fingerprinting the first 10 secs of this test file,
        # shouldn't get more than 3000 hashes.
        self.assertEqual(2554, self.djv.db.get_num_fingerprints())

    def test_recognize_1_file(self):
        self.djv.fingerprint_file("tests/test1.mp3")
        self.djv.fingerprint_file("tests/test2.mp3")
        song = self.djv.recognize(FileRecognizer, "tests/test2.mp3")
        self.assertEqual(song["song_name"], "tests/test2.mp3")
开发者ID:pguridi,项目名称:dejavu,代码行数:36,代码来源:tests_dejavu.py

示例4: open

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
#with open("dejavu.cnf.SAMPLE") as f:

#Directorio de firmas
audiopath= "/home/nego/Descargas/firma"
extension= ".mp3"
audio_paths = get_files_recursive(audiopath, extension)

#Obtener longitud de pistas
for path in audio_paths:
    print "Path %s" % path
    n = get_length_audio(path, extension)
    print "Length %s "%(n)
    config={
    "database": {
    "host": "127.0.0.1",
    "user": "root",
    "passwd": "ksilva",
    "db": "dejavu3"
    },
    "fingerprint_limit": [n]
    }
    # create a Dejavu instance
    djv = Dejavu(config)
    djv.fingerprint_file(path)

#djv.fingerprint_directory(audiopath, [extension])
#Comandos

#print len(sys.argv)
#print str(sys.arv)
开发者ID:enrique26,项目名称:PS,代码行数:32,代码来源:finger.py

示例5: Dejavu

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
# Database URI examples:
# mysql: 'mysql+mysqldb://scott:[email protected]/foo'
# postgresql: 'postgresql://scott:[email protected]/mydatabase'
# sqlite: 'sqlite:///foo.db'
# in memory sqlite:  'sqlite://'

config = {
    "database_backend" : "orm",
    "database_uri": "sqlite:///fingerprints.sqlite",
    "fingerprint_limit" : 10,
}

# previous backend can still be used:
# config = {
#     "database_backend" : "plain",
#     "database": {
#         "host": "127.0.0.1",
#         "user": "",
#         "passwd": "",
#         "db": "",
#     },
#     "fingerprint_limit" : 10,
# }

# create a Dejavu instance
djv = Dejavu(config)

# Fingerprint a file
djv.fingerprint_file("tests/test1.mp3")
开发者ID:pguridi,项目名称:dejavu,代码行数:31,代码来源:fingerprint_file.py

示例6: Dejavu

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import fingerprint_file [as 别名]
for x in original_file:
	limittime=get_length_audio(x,'.mp3')
	print limittime
	config = {
	"database": {
	"host": "127.0.0.1",
	"user": "root",
	"passwd": "ksilva", 
	"db": "dejavu"
	},
	"database_type" : "mysql",
	"fingerprint_limit":limittime
	}
	djv = Dejavu(config)
	print 'x'+x
	djv.fingerprint_file(x)

# 
# if __name__=__main__:
# 	if len(sys.argv)<4:



# if __name__ == '__main__': 
#     if len(sys.argv) != 3: 
#         print "La cantidad de argumentos ingresada no es correcta" 
#     file = sys.argv[1] 
#     action = sys.argv[2] 
#     if action == '-c': 
#         print check(file) 
#     elif action == '-h': 
开发者ID:enrique26,项目名称:PS,代码行数:33,代码来源:firmarDejavu.py


注:本文中的dejavu.Dejavu.fingerprint_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。