SFSpeechRecognizer kLSRErrorDomain 102

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?

Have you been able to fix the issue? I've got the same error. On macOS it works fine, on iOs it gives me this error. url.startAccessingSecurityScopedResource() does not help. Also it works with request.requiresOnDeviceRecognition = false 

After spending a lot of time, what worked for me was enabling and onboarding Siri for iOS. Then downloading models using Settings -> Translate -> (set on-device mode to true), then download models for the specific locale. Then run the app and waiting for some time for the models to download. (It doesn't work immediately).

Then the "supportsOnDeviceRecognition" comes to true immediately when creating the SFSpeechRecognizer() object. Hope this helps someone.

@arunky suggestion worked perfectly first time after I downloaded the languages on Settings -> Translate. However, whenever I launch the app a couple of days later, I get the same error message.

I've rechecked going to Settings -> Translate: the downloaded languages are still there and the on-device mode toggle is still on.

After a while (not that short, can be more than 1 minute), looks to work again. Still, this is unmanageable to get a user-facing app: what should I tell them? Keep trying until the error goes away?

SFSpeechRecognizer kLSRErrorDomain 102
 
 
Q