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?
Post
Replies
Boosts
Views
Activity
I've been playing around with the GameController framework, and have tried to get the charging state of a controller's battery. However, it doesn't seem to be available in the GCDeviceBattery type.
Does anyone know if getting the charging state is possible? Thanks!