Package: audiomatch
A small command-line tool to find similar audio filesInstallationFirst, install theChromaprintfingerprinting library by Lukáš Lalinský. (The library
itself depends on an FFT library, but it’s smart enough to use an algorithm from
software you probably already have installed; see the Chromaprint page for details)Then you can install this library:pipinstallaudiomatchTo do things fastaudiomatchrequires C compiler and Python headers to be installed.
You can skip compilation by settingAUDIOMATCH_NO_EXTENSIONSenvironment variable:AUDIOMATCH_NO_EXTENSIONS=1pipinstallaudiomatchYou can avoid installing all this libraries on your computer and run everything in
docker:dockerrun--rm-v"$(pwd)":/tmpfdooch/audiomatch"/tmp/*"QuickstartSuppose, we have a directory with Nirvana songs:$lsdemoAllApologies(InUtero).m4aDumb(UnpluggedinNYC).m4aAllApologies(UnpluggedinNYC).m4aPennyroyalTea(InUtero).m4aDumb(InUtero).m4aPennyroyalTea(SoloAcoustic).mp3Dumb(RadioAppearance,1991).mp3PennyroyalTea(UnpluggedinNYC).m4aLet’s find out which files sound similar:$audiomatch--length300./demoThesefilessoundsimilar:./demo/AllApologies(InUtero).m4a./demo/AllApologies(UnpluggedinNYC).m4a---./demo/Dumb(InUtero).m4a./demo/Dumb(UnpluggedinNYC).m4a---./demo/PennyroyalTea(InUtero).m4a./demo/PennyroyalTea(SoloAcoustic).mp3./demo/PennyroyalTea(UnpluggedinNYC).m4aNote #1: input audio files should be at least 10 seconds longNote #2: in some rare cases false positives are possibleWhat’s happening here is thataudiomatchtakes all audio files from the directory and
compares them with each other.You can also compare file with another file, file and directory, or directory to
directory. If you need to, you can provide glob-style patterns, but don’t forget to
quote it, because otherwise shell expanded it for you. For example, let’s compare all.mp3files with.m4afiles:$audiomatch"./demo/*.mp3""./demo/*.m4a"Thesefilessoundsimilar:../demo/PennyroyalTea(SoloAcoustic).mp3../demo/PennyroyalTea(UnpluggedinNYC).m4aThis time,audiomatchtook all files with.mp3extension and compare them with
all files with.m4aextension.Note, how there is no In Utero version in the output. The reason it is present in the
previous output, because it actually similar with Unplugged version and then transitive
law applies: ifa = bandb = c, thena = c.–lengthThe--lengthspecifies how many seconds to take for analysis from the song. Default
value is 120 and it is good enough to find exactly the same song, but maybe in different
quality. However, for a more complicated cases like same song played in different tempo
the more input we have the more accurate results are.–extensionBy default,audiomatchlooks for files with.m4a,mp3,.cafextensions.
In theory, audio formats supported byffmpegalso supported byaudiomatch. You can
tell toaudiomatchto look for a specific format by using--extensionflag:$audiomatch-e.ogg-e.wav./demoNotenoughinputfiles.Indeed, we tried to compare files with.oggand.wavextension, but there are
no such files in the demo directory.MotivationI play guitar and do recordings from time to time mainly with Voice Memos on iPhone.
Over the years, I have hundreds of recordings like that and I though it would be cool
to find all the similar ones and see how I progress over the years.That’s why I wrote this library.ReferencesChromaprintandpyacoustidlibrariesExample: How to compare fingerprintsExample: How to compare shifted fingerprints(note: the code is a little bit weird)Explanation: How to compare fingerprintsPopcount in Python with benchmarks