我的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有人知道如何解决这个问题吗?我知道有一些解决办法(例如,用户必须转到Settings->General并切换语音选择),但我不认为这是一个真正的解决方案。
更新:i创建了一个新项目(XCode8 8/Swift3 3/没有其他豆荚/框架等等)。它在模拟器中工作,但在我的设备上给出了同样的错误。
更新2:在设备上工作。我有类似的错误消息(无法复制资产属性等等),但它现在起作用了。我不知道那是什么。
发布于 2016-11-26 16:32:19
关闭您的静音模式(物理开关)。在我的情况下是可行的。
发布于 2017-01-16 01:33:51
我刚在iPad Mini 4上遇到了同样的问题,这个版本没有物理开关。但如果你打开控制中心(滑动),有一个安静的按钮。关掉它,问题就自己解决了。

发布于 2016-12-27 16:14:51
在我的项目中,虽然我很难获得合成来产生初始化后的第一个语句,但我能够通过重新安排代码来解决这个问题。但是,在初始化AVSpeechSynthesizer和产生第一次语句时,仍有数十行垃圾被排入控制台。这里有一个小样本:
2016-12-27 06:45:08.579510 SpeechBug1226[2155:859123] [MobileAssetError:1] Unable to copy asset attributes
2016-12-27 06:45:08.580248 SpeechBug1226[2155:859123] Could not get attribute 'LocalURL': Error Domain=MobileAssetError Code=1 "Unable to copy asset attributes" UserInfo={NSDescription=Unable to copy asset attributes}
2016-12-27 06:45:08.585959 SpeechBug1226[2155:859123] 0x174157fa0 Copy matching assets reply: XPC_TYPE_DICTIONARY <dictionary: 0x174157fa0> { count = 2, transaction: 0, voucher = 0x0, contents =
"Assets" => <data: 0x17426c700>: { length = 1237 bytes, contents = 0x62706c6973743030d4010203040506636458247665727369... }
"Result" => <int64: 0x174220180>: 0我在一个小型演示项目中复制了这个结果,却找不到解决办法。遗憾的是,恐怕这个问题的正确答案是https://bugreport.apple.com/,我刚做了:
https://stackoverflow.com/questions/39879275
复制相似问题