Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving error "Domain=kAFAssistantErrorDomain Code=1101" while setting SFSpeechAudioBufferRecognitionRequest.requiresOnDeviceRecognition = true

I am receiving the next error: Error Domain=kAFAssistantErrorDomain Code=1101 if I'm setting the SFSpeechAudioBufferRecognitionRequest.requiresOnDeviceRecognition = true.

In order to test it you can download the Apple Scrumdinger project from here:

https://developer.apple.com/tutorials/app-dev-training/transcribing-speech-to-text

The only thing that needs to be updated is in SpeechRecognizer.swift, change the prepareEngine function to look like this:

private static func prepareEngine() throws -> (AVAudioEngine, SFSpeechAudioBufferRecognitionRequest) {
    let audioEngine = AVAudioEngine()
    
    let request = SFSpeechAudioBufferRecognitionRequest()
    request.shouldReportPartialResults = true
    request.requiresOnDeviceRecognition = true
    
    let audioSession = AVAudioSession.sharedInstance()
    try audioSession.setCategory(.record, mode: .measurement, options: .duckOthers)
    try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
    let inputNode = audioEngine.inputNode
    
    let recordingFormat = inputNode.outputFormat(forBus: 0)
    inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in
        request.append(buffer)
    }
    audioEngine.prepare()
    try audioEngine.start()
    
    return (audioEngine, request)
}

The only thing that changed was that I added the line: request.requiresOnDeviceRecognition = true

Of course you can go further and test SFSpeechRecognizer in the init to see if it supportsOnDeviceRecognition, but for me returns true.

I am testing on a physical device: iPhone X with iOS 16.0.2.

like image 228
Laur Stefan Avatar asked Sep 16 '25 08:09

Laur Stefan


1 Answers

The error Code=1101 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.

like image 198
KlausM Avatar answered Sep 18 '25 10:09

KlausM