def getSignature(filename, playWhileReading=None): (path, ext) = os.path.splitext(filename) if ext.lower() == '.ogg': ff = ogg.vorbis.VorbisFile(filename) elif ext.lower() == '.mp3': ff = MadWrapper(filename) elif ext.lower() == '.wav': ff = WavWrapper(filename) else: raise SystemError, "Unsupported audio file." if playWhileReading: device = 'esd' id = ao.driver_id(device) aodev = ao.AudioDevice(id) info = ff.info() trm = musicbrainz.trm() trm.SetPCMDataInfo(info.rate, info.channels, 16) while 1: (buff, bytes, bit) = ff.read() if bytes == 0: break if trm.GenerateSignature(buff): break if playWhileReading: aodev.play(buff, bytes) sig = trm.FinalizeSignature() return sig
def getSignature(filename, playWhileReading = None): (path, ext) = os.path.splitext(filename) if ext.lower() == '.ogg': ff = ogg.vorbis.VorbisFile(filename) elif ext.lower() == '.mp3': ff = MadWrapper(filename) elif ext.lower() == '.wav': ff = WavWrapper(filename) else: raise SystemError, "Unsupported audio file." if playWhileReading: device = 'esd' id = ao.driver_id(device) aodev = ao.AudioDevice(id) info = ff.info() trm = musicbrainz.trm() trm.SetPCMDataInfo(info.rate, info.channels, 16) while 1: (buff, bytes, bit) = ff.read() if bytes == 0: break if trm.GenerateSignature(buff): break if playWhileReading: aodev.play(buff, bytes) sig = trm.FinalizeSignature() return sig
def get_trm(ff): info = ff.info() trm = musicbrainz.trm() trm.SetPCMDataInfo(info.rate, info.channels, 16) while 1: (buff, bytes, bit) = ff.read() if bytes == 0: break if trm.GenerateSignature(buff): break return trm.FinalizeSignature()
def getSignature(filename, songLength=None): (path, ext) = os.path.splitext(filename) if ext.lower() == '.wav': ff = WavWrapper(filename) else: raise SystemError, "Unsupported audio file." info = ff.info() trm = musicbrainz.trm() trm.SetPCMDataInfo(info.rate, info.channels, 16) if songLength: trm.SetSongLength(songLength) while 1: (buff, bytes, bit) = ff.read() if bytes == 0: break if trm.GenerateSignature(buff): break sig = trm.FinalizeSignature() return sig