SFSpeechRecognizer on Monterrey error 102
Asked Answered
A

3

7

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?

Amandaamandi answered 8/4, 2022 at 13:4 Comment(1)
Hi, have you been able to find a solution?Ity
V
0

The issue is that you're forcing it to run offline.

request.requiresOnDeviceRecognition = true

This capability requires the A12 bionic, M1, or newer SoC, because these have a neural engine. On devices without a neural engine, you need to perform speech recognition on Apple's servers.

Vallo answered 22/1, 2023 at 14:34 Comment(2)
Not true! Running here offline on an A10X iPad Pro 12.9” 2nd gen…Aaren
Thanks for that information @mramosch, I checked online and found some conflicting information. Apple says that Dictation (which I'm guessing uses the Speech framework too) works without internet connection on the A9 iPhone 6s and later, but I tried on my A9 iPad and this does not work. So it seems that you're right and the requirements might not be limited to just the SoC. Meanwhile, The Verge claims that it requires the A12 - theverge.com/2021/6/7/22522993/….Vallo
B
0

This suggestion offered in Apple's dev forums here worked, at least partially, for me:

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).

I say it worked partially for me, because if I relaunch the app a few days later, the same error message appears. I need to leave the app running idle for quite a bunch of seconds (usually over a minute), which sort of makes it impossible to launch this to final users.

Bandbox answered 1/8, 2023 at 18:6 Comment(0)
D
0

I encountered the error today accidentally. After changing the bundle identifier, the 102 error disappeared.

I believe this happened due to Apple's Speech Recognition Request Limit (1,000 requests per hour). It should resolve itself automatically within a day or two. Then, you can revert back to the original bundle identifier.

Dextrad answered 6/7 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.