Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we solve an AXSpeechAssetDownloader error on iOS?

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?

like image 440
Praxiteles Avatar asked Jun 12 '15 01:06

Praxiteles


4 Answers

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.

like image 194
softwarenerd Avatar answered Nov 15 '22 05:11

softwarenerd


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.

like image 31
Totoro Avatar answered Nov 15 '22 04:11

Totoro


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;
    }
}
like image 34
Satoshi Nakajima Avatar answered Nov 15 '22 04:11

Satoshi Nakajima


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.

like image 26
Petr Lazarev Avatar answered Nov 15 '22 06:11

Petr Lazarev