i already created the bridge however its exhausting to know the documention of ShazamKit .
i’m wondering if there was any concept/assist/supply code to assist me detect music by microphone on a react native software with newest Shazamkit model.
thanks.
i attempted this however i acquired the error: Can’t discover ‘SHMatcher’ in scope
// my swift file
import Basis
import ShazamKit
import AVFoundation
import React
@objc(ShazamBridge)
class ShazamBridge: NSObject {
non-public let audioEngine = AVAudioEngine()
non-public let session = SHSession()
non-public var signatureGenerator = SHSignatureGenerator()
@objc func startListening(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
let inputNode = audioEngine.inputNode
let recordingFormat = inputNode.outputFormat(forBus: 0)
inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in
self.signatureGenerator.append(buffer, at: nil)
}
audioEngine.put together()
do {
strive audioEngine.begin()
} catch {
reject("Error", "Audio engine couldn't begin", error)
}
resolve("Listening began")
}
@objc func stopListeningAndIdentify(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
audioEngine.cease()
audioEngine.inputNode.removeTap(onBus: 0)
let matcher = SHMatcher()
let signature = signatureGenerator.signature()
matcher.addSignature(signature)
session.match(matcher, completion: { (matches, error) in
if let error = error {
reject("Error", "Didn't match audio", error)
} else if let match = matches?.first {
resolve(match.mediaItem.title)
} else {
resolve(nil)
}
})
}
}