ShazamKit

RSS for tag

Get exact audio matching for any audio source using the Shazam catalog or a custom catalog in an app.

ShazamKit Documentation

Posts under ShazamKit tag

32 Posts
Sort by:
Post marked as solved
5 Replies
1.6k Views
I want to create my own custom audio recognition with ShazamKit, when opening the sample project I found the FoodMath.shazamsignature file. I believe there is a way to generate that file based on my audio collections. How do I create the .shazamsignature file? Thanks.
Posted
by
Post marked as solved
3 Replies
853 Views
I was trying to generate a signature from an audio file on-disk. Loading the files work, however generating signatures from them don't seem to work. Here's the code I'm using to generate the signature: func signature(from asset: AVAudioFile) -> SHSignature? {     let format = asset.processingFormat     let frameCount = AVAudioFrameCount(asset.length)           guard let buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: frameCount) else { return nil }     let generator = SHSignatureGenerator()           do {        try asset.read(into: buffer)                let sampleRate = asset.processingFormat.sampleRate                try generator.append(buffer, at: AVAudioTime(sampleTime: .zero, atRate: sampleRate))                return generator.signature()     } catch {        print(error)        return nil     } } There are no errors being thrown in the code, but when I try to use the signatures in an SHSession, the audio is not being recognised. However, using the Shazam library works. I have tried searching ways to do this, however the only examples I've seen are for generating signatures from live audio input. Is there something I'm missing from the code above?
Posted
by
Post not yet marked as solved
1 Replies
593 Views
The operation couldn’t be completed. (com.apple.ShazamKit error 300.) I get this error when I try to add multiple shazamcatalogs on a single SHCustomCatalog. The fact that the operation is called add(from:) and not 'load' lets me suggest that it's meant to use that way. Am I wrong? And yes, both work work if I just add one at a time. let catalog = SHCustomCatalog() do { try catalog.add(from: url1) try catalog.add(from: url2) {...} } catch {...} . . Also, fun fact: I was working on a ShazamKit myself before dubDub and it's a really fascinating topic and so awesome to see how well it works, great job! 👏
Post not yet marked as solved
2 Replies
803 Views
In continuation to this question, I am now able to use ShazamKit in my app, but for every video I pass to it didFailWithSignature is always called: func session(_ session: SHSession,        didNotFindMatchFor signature: SHSignature,                  error: Error?) {         DispatchQueue.main.async {             print("match error: \(String(describing: error))")         }     } with the following output: match error: nil This is happening even with videos that are just screen recorded video clips of Ed Sheeran for example, something that Shazam would easily recognized. Any idea why that would happen? What I should investigate? (the full code is also updated on my GitHub
Posted
by
Post not yet marked as solved
1 Replies
725 Views
I'm creating a simple song-matching application. My steps are: I create a project in XCode. Set bundle ID. Select my team Create an identifier, in my developer account Inserting my bundle ID from Xcode Selecting my team's application ID Turn on ShazamKit in services And after all that, I still get 202 error Error Domain=com.apple.ShazamKit Code=202 "Please check that you have enabled the ShazamKit App Service for this app identifier" UserInfo={NSDebugDescription=Please check that you have enabled the ShazamKit App Service for this app identifier} What am I doing wrong? Could it have something to do with the code?
Posted
by
Post not yet marked as solved
1 Replies
675 Views
Hi, I want to implement ShazamKit in my project. But I have some problems. I use AVCaptureSession to take photos in my app and I'm unable to use ShazamKit. I tried to use three different ways Use an AVAudioEngine during my AVCaptureSession But I didn't obtain any result from Shazam. Try to use ShazamKit after stopping my AvCaptureSession but this causes some problems, and some crashes. Try to use the buffer of my AVCaptureSession to catch audio directly without use AVAudioEngine. This is the code that I use with AVAudioEngine: try! audioSession.setActive(true, options: .notifyOthersOnDeactivation)                 let inputNode = self.audioEngine.inputNode                 let recordingFormat = inputNode.outputFormat(forBus: 0)                                 let audioFormat = recordingFormat //AVAudioFormat(standardFormatWithSampleRate: self.audioEngine.inputNode.outputFormat(forBus: 0).sampleRate,                     //                            channels: 1)                                  inputNode.installTap(onBus: 0, bufferSize: 1024, format: audioFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in                     try! self.signatureGenerator.append(buffer, at: nil)                                          self.session.matchStreamingBuffer(buffer, at: nil)                 }                              self.audioEngine.prepare()                 try! self.audioEngine.start() I can choose two ways to do this, use AVCaptureSession output to pass it to ShazamKit or use an AVAudioSession after the stop of AVCaptureSession. So I have two questions: Can I use a CMSampleBufferRef from AVCaptureSession buffer in a SHSession? And if the answer is yes how? How can I prevent this error if I want to use an AVAudioSession after I stopped my AVCaptureSession? [aurioc]            AURemoteIO.cpp:1117  failed: -10851 (enable 1, outf< 2 ch,      0 Hz, Float32, deinterleaved> inf< 2 ch,      0 Hz, Float32, deinterleaved>) [avae]            AVAEInternal.h:76    required condition is false: [AVAEGraphNode.mm:834:CreateRecordingTap: (IsFormatSampleRateAndChannelCountValid(format))] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)' Thanks
Posted
by
Post not yet marked as solved
1 Replies
607 Views
I'm trying to test ShazamKit on Android. In the following Kotlin snippet, I load apple-test-wav.wav - a 9 second long, 48khz, 16bit PCM WAV audio snippet of the Food Math example video - and attempt to match it against the FoodMath.shazamsignature custom catalog. This audio is not capture via a microphone, it's a clean sample directly from the video and I can't get it to match. The output is always: NoMatch Am I doing something obviously wrong here? override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) CoroutineScope(Dispatchers.IO).launch { searchCatalog() } } private suspend fun searchCatalog() { val file = context?.assets?.open("apple-test-wav.wav") if (file != null) { val bytes = file.readBytes() file.close() val signatureGenerator = (ShazamKit.createSignatureGenerator(AudioSampleRateInHz.SAMPLE_RATE_48000) as ShazamKitResult.Success).data signatureGenerator.append(bytes, bytes.size, System.currentTimeMillis()) val signature = signatureGenerator.generateSignature() val inputStream: InputStream? = context?.assets?.open("FoodMath.shazamsignature") if (inputStream!= null) { val catalog = ShazamKit.createCustomCatalog().apply { addFromCatalog(inputStream) } val session = (ShazamKit.createSession(catalog) as ShazamKitResult.Success).data val matchResult: MatchResult = session.match(signature) println(matchResult.toString()) } else { println("no input stream") } } }
Posted
by
Post not yet marked as solved
1 Replies
486 Views
so i'm learning how to work with ShazamKit on xcode 13 beta 4 and while i'm trying to watch this video https://www.youtube.com/watch?v=KvyQvZYqGL0&list=PL5PR3UyfTWveeb0iCmauh7boDnpCmpMed at 2:33 - the dude said that i need to enable Shazam service if i want ShazamKit to work properly. where do i need to go? how do i find this page?
Posted
by
Post not yet marked as solved
0 Replies
388 Views
Hello Team, Hope you are doing well..!! I am developing a music recognition app by using ShazamKit. I get a MATCH_ATTEMPT_FAILED error every time. So Please let me know how I can fix this issue? Error Log:- Error(exception=com.shazam.shazamkit.ShazamKitMatchException: MATCH_ATTEMPT_FAILED, querySignature=Signature(dataRepresentation=[-128, 37, -128, 37, 1, 0, 0, 0, 12, 0, 0, 0, -128, 37, -2, -54, -100, -90, 21, 112, -36, 1, 0, 0, 0, -100, 32, -108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 56, 32, 1, 0, 0, 0, 124, 0, 0, 0, 0, 64, -36, 1, 0, 0, 64, 0, 3, 96, 75, 0, 0, 0, 16, -9, 110, 107, 15, 13, -124, 110, -118, 11, 5, -63, 109, 124, 10, 15, 101, 113, 57, 13, 6, 63, 108, 119, 8, 0, 88, 112, -68, 12, 10, -103, 110, -93, 14, 9, -79, 109, 71, 16, 8, 5, 111, -9, 9, 11, 85, 110, 120, 15, 3, -96, 112, 60, 9, 13, -113, 110, -16, 10, 15, 103, 111, 58, 8, 18, 28, 110, -17, 15, 14, -46, 112, 65, 14, 0, 65, 0, 3, 96, 120, 0, 0, 0, 27, 40, 112, 56, 30, 3, -111, 112, 77, 21, 6, -6, 110, -71, 31, 4, 21, 120, -1, 25, 5, 4, 111, -77, 40, 2, 82, 111, 85, 23, 14, 26, 111, -128, 19, 6, 14, 111, 0, 29, 1, -54, 109, 85, 42, 0, 95, 111, 39, 46, 3, 63, 113, -106, 32, 3, 6, 112, 117, 39, 14, -32, 119, 16, 26, 6, 38, 113, -64, 29, 7, -3, 110, 48, 17, 8, 5, 111, -62, 31, 1, 108, 110, 71, 37, 5, -67, 109, 64, 31, 4, 22, 111, 110, 22, 7, -41, 110, 63, 42, 2, 3, 111, -22, 22, 13, -43, 110, -65, 34, 11, -105, 110, -18, 17, 4, 39, 110, 84, 43, 66, 0, 3, 96, 120, 0, 0, 0, 14, -110, 111, 15, 67, 6, 29, 112, -117, 65, 3, -15, 119, 20, 78, 4, -17, 111, 24, 52, 2, 64, 113, -8, 83, 13, 41, 113, -73, 71, 4, -56, 113, -107, 103, 11, -1, 111, -102, 73, 5, -4, 111, 112, 96, 2, -123, 114, -57, 50, 8, 101, 112, 52, 72, 6, -121, 112, 7, 83, 16, -34, 111, -43, 65, 0, 124, 120, 19, 78, 1, -34, 111, -119, 70, 6, -123, 113, -54, 108, 17, 106, 111, -56, 84, 4, -43, 111, 68, 69, 6, 96, 111, -62, 55, 6, -78, 111, -48, 111, 9, 99, 112, -6, 102, 1, 74, 113, 18, 58, 5, -8, 111, -3, 96, 1, 8, 113, 94, 104, 67, 0, 3, 96, 120, 0, 0, 0, 19, 19, 112, 49, -122, 2, -128, 111, -64, 116, 5, -77, 112, -81, -90, 1, 110, 113, -20, -96, 4, 81, 113, -56, -111, 23, -57, 111, -109, -82, 3, 110, 111, -11, -122, 6, 8, 112, -38, 112, 15, 17, 113, -6, -81, 2, -72, 111, -2, 125, 15, -46, 111, 13, -110, 1, 100, 111, -106, 113, 3, 83, 119, 49, -126, 0, -87, 113, -64, -84, 3, 29, 112, -74, -110, 5, -86, 111, -125, 124, 5, 58, 112, 123, -109, 1, 54, 112, 66, 122, 5, 72, 111, -99, -94, 23, -96, 112, -17, -92, 3, 31, 113, 44, -101, 4, 54, 112, -84, -96, 4, -69, 112, 52, -100, 3, 66, 111, -14, -110], durationInMs=1297, audioStartTimestamp=b.a.a.a.d@9c5d28e0))
Posted
by
Post not yet marked as solved
1 Replies
349 Views
Hello good morning lovely ShazamKit team! I was wondering if there's a way to evaluate the result (SHMatch) to be able to estimate if this is a very good match (the catalog is very certain that this is correct), or if this is at the lower end of the spectrum of certainty. Thanks a lot and have a nice day! – Frederik
Posted
by
Post not yet marked as solved
0 Replies
360 Views
We try to implement shazamkit music recognition in our app. All works amazing but, SHSession return track information in english translit, but when we open web url, it show right language. Region and language set as Ru on device.
Posted
by
Post not yet marked as solved
0 Replies
330 Views
I want to create and publish Android app which uses ShazamKit, but I can't find License Agreement for Android version of ShazamKit, which means I can't publish APK legally. also I want to include aar file to GitHub repository for build in CI, but I can't include aar file legally without explicit allow from Apple. Where is the License Agreement for Android version of ShazamKit?
Posted
by
Post not yet marked as solved
2 Replies
479 Views
Today, I create a small app to try ShazamKit music detection ability in iOS 15. Follow a tutorial on Youtube, and I have Apple developer membership and have enabled the ShazamKit service for this app identifier. In short, I want to detect a song metadata with ShazamKit from the audio file inside app. The problem is that both of delegate method didFind and didNotFindMatchFor didn't fire though I have generated the signature successfully. I think it should give me an error in didNotFindMatchFor delegate method if there is no match found at least, but it doesn't. It's a pretty new feature, there is not that much related stuff I could find. What am I missing here? Appreciate for any help. More info: I do find some stuff using audioEngine, however that use output from Microphone, if user listen music with a headphone, that would be not possible. In my case I want to use the file itself since my production app is a music player, which stores a lot audio files in sandbox. import ShazamKit import UIKit class ViewController: UIViewController { lazy var recoButton: UIButton = { let button = UIButton(frame: CGRect(x: 0, y: 0, width: 120, height: 60)) button.layer.cornerRadius = 8 button.backgroundColor = .brown button.setTitle("Recognize", for: .normal) button.addTarget(self, action: #selector(recognizeSong), for: .touchUpInside) return button }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(recoButton) recoButton.center = view.center } @objc func recognizeSong(_ sender: UIButton) { print("reco button tapped") // ShazamKit is available from iOS 15 if #available(iOS 15, *) { // session let session = SHSession() // delegate session.delegate = self do { // get track guard let url = Bundle.main.url(forResource: "Baby One More Time", withExtension: "mp3") else { print("url is NULLLL") return } // create audio file let file = try AVAudioFile(forReading: url) let frameCapacity = AVAudioFrameCount(file.length / 26) // Audio -> Buffer guard let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: frameCapacity) else { print("Failed to create a buffer") return } // Read file into buffer try file.read(into: buffer) // SignatureGenerator let generator = SHSignatureGenerator() try generator.append(buffer, at: nil) // create signature let signature = generator.signature() // try to match session.match(signature) } catch { print(error) } } else { // unavailable alert } } } extension ViewController: SHSessionDelegate { func session(_ session: SHSession, didFind match: SHMatch) { print("Match found!") // get results let items = match.mediaItems items.forEach { item in print(item.title ?? "title") print(item.artist ?? "artist") print(item.artworkURL?.absoluteURL ?? "artwork url") } } func session(_ session: SHSession, didNotFindMatchFor signature: SHSignature, error: Error?) { if let error = error { print(error) } } }
Posted
by
Post not yet marked as solved
1 Replies
391 Views
Hey, I wanted to use the ShazamKit API in a web application but it seems like the framework is only for iOS and Android. I came across this resource but it's not very clear how it works as they direct traffic to their own server: https://rapidapi.com/apidojo/api/shazam Does anyone know if there is an official URL for the Shazam API and how I can use it? Thanks
Posted
by
Post not yet marked as solved
0 Replies
358 Views
This is first time I am developing android app using sdk provided by Apple. I want to integrate Shazamkit in my app but after going through all documents & steps, I got my private key, team id everything except "Public key" for token, as I am not able to create valid access token using jwt, I am not able to use ShazamKit. So if possible please let me know from where I can get this key or am I missing some step? Thank you in advance.
Posted
by
Post not yet marked as solved
0 Replies
483 Views
Hi all, I have an app that is playing music from http live streams using AVPlayer. Have been trying to figure out how to use ShazamKit to recognise the music playing but I just can't figure out how to do it :-( Works well with local files and microphone recordings, but how do I get the data from a stream that is currently playing??? Feels like I tried everything... Have tried to install an MTAudioProcessingTap but it doesn't seem to work on streaming assets even though I can get hold of the proper AVAssetTrack containing the audio. No callback with data are received? Bug? I can open the streaming url and just save the bytes to disk and that's fine, but I'm not in sync with what is playing in AVPlayerItem so the recognition isn't working with the same audio data as the user is currently hearing. Hmmm. Any suggestions and ideas are welcome. It would be such a nice feature for my app so I'm really looking forward to solving this. Thx in advance / Jörgen, Bitfield
Posted
by
Post marked as solved
3 Replies
527 Views
Hello, we've encountered issues on Android using Custom Catalogs. On Android the only possible way to create a custom catalog is using .addFromCatalog() from a .shazamcatalog file, there is no method like iOS SDK provides .addReferenceSignature() to add a signature. Generating from iOS a .shazamcatalog file and loading in Android returns wrong values for query signature duration: Android catalog.minimumQuerySignatureDurationInMs: 3000 catalog.maximumQuerySignatureDurationInMs: 2147483647 iOS minQuerySignDuration: 1.0 seconds maxQuerySignDuration: 12.0 seconds No match resulting for Android but iOS works as expected. Is it possible to match against a custom catalog on Android? Any help will be much appreciated.
Posted
by
Post not yet marked as solved
1 Replies
536 Views
Hi, I'm developing an android app that uses ShazamKit. I know that there is an hourly requests rate limit for the Apple Music API, but I can't find anything about ShazamKit. Is there also a rate limit for ShazamKit? If yes, how can I find it since I'm using the SDK and not doing direct call API?
Posted
by
Post not yet marked as solved
1 Replies
372 Views
The resulted matches from a custom catalog on both iOS/ Android are a bit delayed (1-3+ seconds) How to test? (iOS) Prepare AVAudioPlayer with recorded audio. Load custom catalog & listen to recorded audio from an external source. When a match is found, play recorded audio from the AVAudioPlayer at: predictedCurrentMatchOffset Result: 1-3+ seconds delayed matches Question How to improve or filter the resulting matches to be close if not exact to the external audio source? Experimental Filtering results by frequencySkew close to 0, does not minimize delayed matches. [{     "sh_audioStartDate" = "2021-11-24 12:34:42 +0000";     "sh_frequencySkew" = "2.222024e-05";     "sh_matchOffset" = "388.3738065670163";     "sh_score" = "4302.546";     "sh_speedSkew" = "0.0009712927";     "sh_title" = ItemTitle; }] Printing the matchedMediaItems, there is a “sh_score”, maybe we can experiment with? But it’s not a public property Best regards.
Posted
by