How to Make Sfspeechrecognizer Available on MACos

How to make SFSpeechRecognizer available on macOS?

Had similar problems with SFSpeechRecognizer... Perhaps you can set the delegate of SFSpeechRecognizer before requesting for authorization, as shown here.

For example:

class ViewController: NSViewController {
var speechRecognizer: SFSpeechRecognizer!

override func viewDidLoad() {
super.viewDidLoad()
speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))
speechRecognizer.delegate = self
}

override func viewWillAppear() {
SFSpeechRecognizer.requestAuthorization { authStatus in
...
}

if !speechRecognizer.isAvailable {
print("Not available!")
}

let url = Bundle.main.url(forResource: "sample", withExtension: "mp3")!
let request = SFSpeechURLRecognitionRequest(url: url)

// will now ask for authorisation
speechRecognizer.recognitionTask(with: request) { (result, error) in
...
}
}
}

extension ViewController: SFSpeechRecognizerDelegate {

}

Then the authorisation dialog will be properly shown.

In addition, it seems that only when there is a call to recognitionTask, that the user will be asked to give permission. Instead, calling requestAuthorization alone will not have any effect.

SFSpeechRecognizer isn't working properly in IOS 13.2

I have been experiencing the same problem with iOS 13.2

Apple just released iOS 13.3, and fixed the bug you are experiencing with SFSpeechRecognizer.

The same bug in macOS Catalina 10.15.1 has been fixed with the just released macOS Catalina 10.15.2

speech to text macOS swift playground

It seems like the Speech library is only available on iOS, so you're out of luck with SFSpeechRecognizer. NSSpeechRecognizer could be an alternative but requires you to give a list of words for it to recognize from (rather than recognizing from any arbitrary word).



Related Topics



Leave a reply



Submit