Created
November 9, 2019 04:52
-
-
Save anupamchugh/a2f3d5a5b04829d1ba3e065a47df299c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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