Error throws while using the speech recognition service in my app

Recently I updated to Xcode 14.0. I am building an iOS app to convert recorded audio into text. I got an exception while testing the application from the simulator(iOS 16.0).

[SpeechFramework] -[SFSpeechRecognitionTask handleSpeechRecognitionDidFailWithError:]_block_invoke Ignoring subsequent recongition error: Error Domain=kAFAssistantErrorDomain Code=1101 "(null)" Error Domain=kAFAssistantErrorDomain Code=1107 "(null)"

I have to know what does the error code means and why this error occurred.

let recognitionRequest = SFSpeechAudioBufferRecognitionRequest()
recognitionRequest?.requiresOnDeviceRecognition = false // fixes 1101 err

fixed issue causing 1101 error in iOS 17.0 simulator for me

I get the same error 1107 when trying to recognize m4a file having length 6 min, 1.5 MB. Around 2 mins of audio is recognized ok, then failure always happens in the same place. In Console app I see the following messages:

EXC_RESOURCE -> localspeechrecognition[17858] exceeded mem limit: ActiveSoft 300 MB (non-fatal)
155685.706 memorystatus: killing_highwater_process pid 17858 [localspeechrecognition] (highwater 10) 315553KB - memorystatus_available_pages: 33068 compressor_size:63118
Process localspeechrecognition [17858] killed by jetsam reason highwater

So it seems there is some memory limit for speech recognition process. I don't know if hitting 300 MB limit is adequate for such audio file.

iOS 16.7.2

The error Code=1101 often has to do with incorrect/incomplete setup off offline dictation on your device.

If you set request.requiresOnDeviceRecognition = true the recognition process uses Apple’s dictation service.

The dictation service only works offline if

  1. you have the keyboard installed for the same language + region you want the dictation / speech recognition for
  2. you have Enable Dictation toggled On and
  3. the Dictation Language for the lang + region you want has been downloaded by the system.

If the above conditions are not met, you will see the 1101 error.

Example:

If you want offline dictation for „de-DE“ (german language for region Germany) you need to have such a keyboard installed. In the device's Setting / General / Keyboard / Keyboards … be sure to have the one keyboard installed for your lang + region speech recognition (in our example „German (Germany)“). Further down in General / Keyboard turn on Enable Dictation. If Dictation is enabled, you see a further entry below called Dictation Languages. Open it to make sure the dictation languages are downloaded (you see a note about the status there).

Once the dictation language(s) are downloaded, speech recognition with request.requiresOnDeviceRecognition = true should work for that language/region.

Appreciate the replies everyone. @John47377 your response is really interesting. I see the error below after roughly 1000 seconds of running the SFSpeechRecognizer. Interestingly it fails at not the same exact time, which makes me think it could be a memory issue. I'm going to try a solution where I reinitialize the SFSpeechRecognizer proactively, say at 500 seconds, and accept a brief disruption in recognition.

[SFSpeechRecognitionTask handleSpeechRecognitionDidFailWithError:]_block_invoke Ignoring subsequent recongition error: Error Domain=kAFAssistantErrorDomain Code=1101 "(null)" Error Domain=kAFAssistantErrorDomain Code=1107 "(null)"

Error throws while using the speech recognition service in my app
 
 
Q