I'm getting this error as well.
My usage:
feed an mp3 file into the speech
requiresOnDeviceRecognition is set to true
addsPunctuation is set to true, but setting to false doesn't fix anything
app being ran in foreground
Hardware: iPhone 11
Workaround:
Restart the device. Quitting the app is not good enough.
Split large audio into smaller chunks
Why it's not just the audio I'm transcribing: when I restart the device the exact same audio will transcribe
What I haven't tried: using audio buffers instead of feeding it a file.
Digging a bit deeper:
CPU usage is low
Memory usage is low (so it's not an OOM on my app's side
using [weal self] or [unowned self] in recognizer?.recognitionTask(with: request) makes no difference. I know that in the Lock Screen remote control that using weak self will cause a crash.
recognizer?.recognitionTask(with: request) {...} this closure gets called between 74 to 130 times before error is thrown. In the calls before the error, transcription is present, but metadata and transcription segment duration is not present. However, I've seen one example where metadata and transcription comes in before a couple times before the error.
setting locale manually does not fix it
request.shouldReportPartialResults = false does not fix it
recognizer?.defaultTaskHint = .dictation does not fix it
recognizer?.queue = OperationQueue() does not fix it
using delegate vs closure for task callback did not fix it
Ideal resolution from Apple:
Send a more helpful error so we know what we did wrong
If it's a bug in Speech framework given that restarting the device fixes it
Let us know if this is a priority for a fix (so that we can plan accordingly)