Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created November 9, 2019 04:52
Show Gist options
  • Save anupamchugh/a2f3d5a5b04829d1ba3e065a47df299c to your computer and use it in GitHub Desktop.
Save anupamchugh/a2f3d5a5b04829d1ba3e065a47df299c to your computer and use it in GitHub Desktop.
private func startAudioEngine() {
do {
let request = try SNClassifySoundRequest(mlModel: soundClassifier.model)
try analyzer.add(request, withObserver: resultsObserver)
} catch {
print("Unable to prepare request: \(error.localizedDescription)")
return
}
audioEngine.inputNode.installTap(onBus: 0, bufferSize: 8000, format: inputFormat) { buffer, time in
self.analysisQueue.async {
self.analyzer.analyze(buffer, atAudioFramePosition: time.sampleTime)
}
}
do{
try audioEngine.start()
}catch( _){
print("error in starting the Audio Engin")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment