Skip to main content

A small command-line tool to find similar audio files

Project description

Build Status Coverage Status PyPI Package latest release MIT License

A small command-line tool to find similar audio files

Installation

First, install the Chromaprint fingerprinting 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:

pip install audiomatch

To do things fast audiomatch requires C compiler and Python headers to be installed. You can skip compilation by setting AUDIOMATCH_NO_EXTENSIONS environment variable:

AUDIOMATCH_NO_EXTENSIONS=1 pip install audiomatch

You can avoid installing all this libraries on your computer and run everything in docker:

docker run --rm -v "$(pwd)":/tmp fdooch/audiomatch "/tmp/*"

Quickstart

Suppose, we have a directory with Nirvana songs:

$ ls demo
All Apologies (In Utero).m4a           Dumb (Unplugged in NYC).m4a
All Apologies (Unplugged in NYC).m4a   Pennyroyal Tea (In Utero).m4a
Dumb (In Utero).m4a                    Pennyroyal Tea (Solo Acoustic).mp3
Dumb (Radio Appearance, 1991).mp3      Pennyroyal Tea (Unplugged in NYC).m4a

Let’s find out which files sound similar:

$ audiomatch --length 300 ./demo
These files sound similar:

./demo/All Apologies (In Utero).m4a
./demo/All Apologies (Unplugged in NYC).m4a

---

./demo/Dumb (In Utero).m4a
./demo/Dumb (Unplugged in NYC).m4a

---

./demo/Pennyroyal Tea (In Utero).m4a
./demo/Pennyroyal Tea (Solo Acoustic).mp3
./demo/Pennyroyal Tea (Unplugged in NYC).m4a

Note #1: input audio files should be at least 10 seconds long

Note #2: in some rare cases false positives are possible

What’s happening here is that audiomatch takes 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 .mp3 files with .m4a files:

$ audiomatch  "./demo/*.mp3" "./demo/*.m4a"
These files sound similar:

../demo/Pennyroyal Tea (Solo Acoustic).mp3
../demo/Pennyroyal Tea (Unplugged in NYC).m4a

This time, audiomatch took all files with .mp3 extension and compare them with all files with .m4a extension.

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: if a = b and b = c, then a = c.

–length

The --length specifies 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.

–extension

By default, audiomatch looks for files with .m4a, mp3, .caf extensions. In theory, audio formats supported by ffmpeg also supported by audiomatch. You can tell to audiomatch to look for a specific format by using --extension flag:

$ audiomatch -e .ogg -e .wav ./demo
Not enough input files.

Indeed, we tried to compare files with .ogg and .wav extension, but there are no such files in the demo directory.

Motivation

I 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.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiomatch-0.2.2.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

audiomatch-0.2.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (66.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64manylinux: glibc 2.5+ x86-64

File details

Details for the file audiomatch-0.2.2.tar.gz.

File metadata

  • Download URL: audiomatch-0.2.2.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.8.13 Linux/5.15.0-1017-azure

File hashes

Hashes for audiomatch-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2c8265387c83dacf59725084a44c554c5b4bfb0d5d94bbd9e4ac3982d3074390
MD5 0a12fdcaecefad3bd5bd21c23ed053cc
BLAKE2b-256 09373beb3e09f632dafad6ad912f7a515fc4e24f7ab73c2261239813fc4b153a

See more details on using hashes here.

File details

Details for the file audiomatch-0.2.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for audiomatch-0.2.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c74eda43b48741aa330c2ecb5cc9166c03c2b6e818cf82c9a62a8567dffd52ba
MD5 c8a7ab16b3d3a310240e3e9b8e280c74
BLAKE2b-256 3bae0386e70df1ebfd27962c395dc1ac2f19c0c93d9536c098ee1178a714bb05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page