Created
March 31, 2020 13:57
-
-
Save FedeRotoli/d16d570974fe0aca1c53f86dcb23e4bf 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