How do we solve an AXSpeechAssetDownloader error on iOS?

6.8k views Asked by At

We have an iOS app that uses AVSpeechSynthesizer to speak. It works on the iPad and other devices - but we notice it is not working on our iPhone 6 Plus.

When examining the console output we see this error:

|AXSpeechAssetDownloader|error| ASAssetQuery error fetching results Error Domain=ASError Code=21 "The operation couldn’t be completed. (ASError error 21 - Unable to copy asset information)" UserInfo=0x174a7e100 {NSDescription=Unable to copy asset information}

The device on which the app is running does have a network connection.

Any ideas how to even begin solving this?

5

There are 5 answers

1
Petr Lazarev On

You may see this error also if you are passing string into AVSpeechUtterance constructor in language A, but asking to speech it using language B.

Example:

let utterance = AVSpeechUtterance(string: "Hello")
utterance.voice = AVSpeechSynthesisVoice(language: "pl-PL")

In this case "Hello" is not a Polish language (pl-PL). App shows such Error and may (in some cases) speeches text.

0
Zyntx On

For me, I was able to resolve this by setting the utterance.voice after the utterance string.

speechUtterL1 = AVSpeechUtterance(string: ("أتمنى لك نهارا سعيد")) 
speechUtterL1.voice = AVSpeechSynthesisVoice(language: "ar-SA")

The reverse, where I set the voice only once results in an error:

[TTS] Error running custom voice query Error Domain=ASError Code=15 "Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.VoiceServices.GryphonVoice" UserInfo={NSDescription=Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.VoiceServices.GryphonVoice}

1
Totoro On

This means that the resources required to speak the required languages have not been downloaded, and the app failed to do that automatically. as @softwarenerd mentions, you can go to Settings -> General -> Speech, and then go to Voices and download whatever voices you need.

But then, this is not really a good solution if you are developing the app for the app store. There must be a way to handle the download automatically and on demand.

1
Satoshi Nakajima On

I see the exact same problem on iOS9. Here is my work-around, which is not perfect but at least avoids the crash.

let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
    if lang == voice.language {
        utterance.voice = voice
        break;
    }
}
2
softwarenerd On

I was having the same issue. I couldn't find any help, so, I had to debug it by trying various things.

What I found is that if you access Settings -> General -> Speech, and enable "Speak Selection" and muck about with the English voice, it will just start working for you.

Let me know if this helps.