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?
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.
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.
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;
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With