私の AVSpeechSynthesizer コードはデバイス (iOS 10) では動作しませんが、iOS 9.x では動作し、現在はシミュレーターでも動作しています。
let str = self.audioOutput //just some string here, this string exists, and it's in english
let synth = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: str)
utterance.rate = AVSpeechUtteranceDefaultSpeechRate
let lang = "en-US"
utterance.voice = AVSpeechSynthesisVoice(language: lang)
synth.speakUtterance(utterance)
次のエラーが発生します:
MobileAssetError:1] Unable to copy asset attributes
Could not get attribute 'LocalURL': Error Domain=MobileAssetError Code=1 "Unable to copy asset attributes"
UserInfo={NSDescription=Unable to copy asset attributes}
0x1741495e0 Copy assets attributes reply: XPC_TYPE_DICTIONARY <dictionary: 0x1741495e0> { count = 1, transaction: 0, voucher = 0x0, contents =
"Result" => <int64: 0x1744203a0>: 1}
それ以前は次のようなエラーメッセージがありました:
Unable to copy asset information from https://mesu.apple.com/assets/ for asset type
この問題を解決する方法を誰か知っていますか? 回避策がいくつかあることは知っています (たとえば、ユーザーは [設定] -> [一般] に移動して [選択内容の読み上げ] を切り替える必要があります) が、これが本当の解決策だとは思いません。
アップデート:新しいプロジェクトを作成しました (XCode8/Swift3/他のポッド/フレームワークなどなし)。シミュレーターでは動作しますが、デバイス上では同じエラーが発生します。
アップデート2:デバイス上で動作します。同様のエラー メッセージ (アセット属性をコピーできないなど) が表示されますが、今のところは動作します。原因はわかりません。
ベストアンサー1
サイレント モード (物理スイッチ) をオフにします。私の場合はこれでうまくいきました。