Obscure kAFAssistantErrorDomain Codes and Other Speech Issues

Hello, I've been trying to implement some features in an app that uses iOS's Speech API but have run into some problems I haven't been able to solve for months:

  • Most Important: What do these obscure errors mean and how can I fix them? Mostly I get kAFAssistantErrorDomain 203/1107 "(Null)" but occasionally others. The localized error message simply says "The operation couldn't be completed." There are no results on Google for these errors and no mention in the documentation.
  • result.BestTranscription.formattedString keeps resetting, e.g.,


My

My name

My name is Paul, //(All okay so far)

and //(Resets here for some reason)

and I

and I program.


Expected final result: "My name is Paul, and I program."

Actual final result: "and I program."

  • Transcriptions sometimes rip full names/other personal details out of the client phone and place them into the transcription (e.g., The square root of Ryan Tracy is 27). Is there any way to disable this feature? In the future, I plan to provide contextual strings.
  • I'm using on-device recognition to transcribe hours-long recordings (I'm requiring on-device recognition support so I don't hog Apple servers). However, I can't seem to keep recognition running in the background. Is there a solution to this? Alternatively, can I pause a recognition process when backgrounding and pick up where I left off when the app is next opened?


Any help with these issues would be appreciated!

Replies

Hello, I have almost the same issues.

Errors

Specifically, kAFAssistantErrorDomain Code=1107 "(null)". I have no idea what does it means and how should I fix it.

Transcription

This is not a problem. Look how i handle it:

extension TranscribeVC: SFSpeechRecognitionTaskDelegate {

    func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didFinishRecognition recognitionResult: SFSpeechRecognitionResult) {
        result.append(contentsOf: recognitionResult.bestTranscription.formattedString)
        result.append(contentsOf: ".\n")
    }

    func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didFinishSuccessfully successfully: Bool) {
        DispatchQueue.main.async {
            if successfully {
                self.textView.text = self.result
            }
        }
    }

But I set localRecognitionRequest.shouldReportPartialResults = false

It works this way, because full audio file breaks by segments, and then they recognized. So, when you take result of recognition, you get only last segment.

Using user data to transcribe

I think this feature was included for better transcribing results, and for now It seems like this feature is mandatory.

Background recognition

Same problem. Still can't find the solution to run recognition task in background.