ShazamKit with custom catalog match issue

I have the following situation:

  • I took 3 audio files and generated a Shazam signature for each
  • I created a custom catalog with these 3 signatures
  • All 3 audio items have an identical 40 second intro

When I create a SHSession with my custom catalog and try to match audio from that common intro section, the matcher returns on the delegate method session(_ session: SHSession, didFind match: SHMatch) - without exception - only 1 object in the match.mediaItems array.

For example: if didFind is called once per second, for signatures A, B, C, I would get a random sequence like - A, B, A, A, C, C, B, A (it's different every time).

According to the documentation, mediaItems should contain all 3 sounds represented by the signatures as possible matches: mediaItems - An array of the media items in the catalog that match the query signature, in order of the quality of the match.

The catalog was built by loading the signature files from disk:

let signatureData = try Data(contentsOf: sigUrl)
let signature = try SHSignature(dataRepresentation: signatureData)
let mediaItem = SHMediaItem(properties: [.title: sigName])
try customCatalog.addReferenceSignature(signature, representing: [mediaItem])

I tried matching:

  • with session.matchStreamingBuffer(buffer, at: audioTime) (so sending the audio input directly to the matching session)
  • by creating a signature of the recorded audio for different durations (from 3 to 15 seconds recording duration) and sending the signature to the matcher to session.match(signature).
  • I also tried the async/await version, for the small chance of implementation differences between the two

but I always, without exception, only get 1 item in the mediaItems array.

Everything else seems to be working correctly - apart from matching within the common section.

Does anyone have any suggestions about this? Is it expected behaviour or a ShazamKit bug?

Answered by in 720589022

Hello, I can confirm that this is the expected behaviour for Custom catalogs.

  • Media items are associated with a particular signature, so they will only be returned if their signature is matched

  • ShazamKit will never return a match for multiple signatures.

Because the signatures have common sections it is undefined as to which will be returned, as shown by the match jumping between the various signatures. 

If you do want to achieve a consistent match when there are common sections I would recommend checking out this years WWDC video, and specifically “frequencySkewRanges”.  Create custom catalogs at scale with ShazamKit

Let me know if you need any more help

Accepted Answer

Hello, I can confirm that this is the expected behaviour for Custom catalogs.

  • Media items are associated with a particular signature, so they will only be returned if their signature is matched

  • ShazamKit will never return a match for multiple signatures.

Because the signatures have common sections it is undefined as to which will be returned, as shown by the match jumping between the various signatures. 

If you do want to achieve a consistent match when there are common sections I would recommend checking out this years WWDC video, and specifically “frequencySkewRanges”.  Create custom catalogs at scale with ShazamKit

Let me know if you need any more help

So you are saying that the returned mediaItems array will only ever contain one match?

I built a custom catalog for a client that has about 50,000 original audio tracks in its inventory. The point was to help identify duplicates, as some audio has been renamed and reloaded into the media management system over the years for one reason or another.

The hope was that shazamKit would return an array of matches when searching with a single querySignature, IF there were multiple identical tracks in the inventory... There is at least one case where three identical audio tracks have been added, but as the OP states, the returned 'Array' only contains a single match, not all three.

Is there really no way to get - (void)matchSignature:(SHSignature*)signature toreturn an array of ALL matches in the catalog??

Thanks!

Thanks - I'll do that. My current workaround involves running the entire library through Shazam, and storing the result of each match that returns a different fileID (the metadata used) in a table, and then walking the table searching for other references to each match... I don't have a great deal of confidence that it's 100%, but it does generate many sets of duplicate audio tracks - even one with 4 members! Thanks again.

ShazamKit with custom catalog match issue
 
 
Q