Last active
September 30, 2019 19:01
-
-
Save dbolella/50abb41c01520009d1938e3769378f2a to your computer and use it in GitHub Desktop.
Setting up SFSpeechRecognizer for Audio Buffers
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 let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))! | |
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest? | |
private var recognitionTask: SFSpeechRecognitionTask? | |
private func setupRecognition() { | |
let recognitionRequest = SFSpeechAudioBufferRecognitionRequest() | |
recognitionRequest.shouldReportPartialResults = true | |
recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest) { [weak self] result, error in | |
result!.bestTranscription.formattedString | |
} | |
self.recognitionRequest = recognitionRequest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment