I have updated to macOS Monterrey and my code for SFSPeechRecognizer just broke. I get this error if I try to configure an offline speech recognizer for macOS
Error Domain=kLSRErrorDomain Code=102 "Failed to access assets" UserInfo={NSLocalizedDescription=Failed to access assets, NSUnderlyingError=0x6000003c5710 {Error Domain=kLSRErrorDomain Code=102 "No asset installed for language=es-ES" UserInfo={NSLocalizedDescription=No asset installed for language=es-ES}}}
Here is a code snippet from a demo project:
private func process(url: URL) throws {
speech = SFSpeechRecognizer.init(locale: Locale(identifier: "es-ES"))
speech.supportsOnDeviceRecognition = true
let request = SFSpeechURLRecognitionRequest(url: url)
request.requiresOnDeviceRecognition = true
request.shouldReportPartialResults = false
speech.recognitionTask(with: request) { result, error in
guard let result = result else {
if let error = error {
print(error)
return
}
return
}
if let error = error {
print(error)
return
}
if result.isFinal {
print(result.bestTranscription.formattedString)
}
}
}
I have tried with different languages (es-ES, en-US) and it says the same error each time.
Any idea on how to install these assets or how to fix this?