Created
September 13, 2021 23:06
-
-
Save rudrankriyam/50c00fe588bd7a86610c6ba7011be012 to your computer and use it in GitHub Desktop.
HomeViewModel recognition
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
public func startRecognition() { | |
feedback.prepare() | |
// 1 | |
do { | |
if engine.isRunning { | |
stopRecognition() | |
return | |
} | |
// 2 | |
try prepareAudioRecording() | |
generateSignature() | |
try startAudioRecording() | |
feedback.notificationOccurred(.success) | |
} catch { | |
// Handle errors here | |
print(error) | |
feedback.notificationOccurred(.error) | |
} | |
} | |
public func stopRecognition() { | |
isRecognizingSong = false | |
engine.stop() | |
engine.inputNode.removeTap(onBus: .zero) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment