Swift

Use The Shazam Binary To Capture Signatures Of Audio Tracks In Batches

One of my favorite moments at Apple’s WWDC was when I got to see the developers of Shazam show off their new creation. A few years later, in 2017, Apple acquired Shazam. In the few years since, they have released ShazamKit, an API that Apple documented at https://developer.apple.com/documentation/shazamkit. ShazamKit allows independent developers to harness the abilities of Shazam to create their own audio pattern-matching services.

One small part of Shazam is important in that it’s the input the powerful signature analysis capabilities of the platform. This is fed by .shazamsignature files that can be captured and then compared to other signatures. The APIs are integral to developing apps that can pattern match files captured; however, capturing and analyzing files can be done with small shell scripts. To aid in this, Apple exposed the SHSignature object to a binary at /usr/bin/shazam. The Shazam binary can then

shazam signature --input /Users/charlesedge/Desktop/test.wav  --output out.shazamsignature

The tested file types that I’ve tested that can be analyzed by ShazamKit include .wav, .m4a, and .mp3. Once captured, signatures can then be placed into a catalog using the SHCatalog base class documented at https://developer.apple.com/documentation/shazamkit/shcatalog. Custom catalogs can then be added onto a host with the shazam command as well.

shazam custom-catalog display --input output.shazamcatalog

Matching is done with the SHMatch object. This needs to be done in swift. The ability to work with sound files manually though allows a devops team to create audio and analyze the signatures that can then be picked up by an app – often much quicker (if slightly less efficient) than developing those pieces in other languages. The API endpoints mentioned and the binaries can then be used by anyone to develop their own apps that do much of what Shazam does. This might be analyzing sounds of creatures or known ailments for industrial equipment and isn’t constrained to just the latest string of hits by Taylor Swift (who the swift programming language was obviously named after).