AVSpeechSynthesizer errors in iOS 10

不打扰是莪最后的温柔 提交于 2019-12-09 19:17:23

问题


I'm currently creating a text-to-speech app using AVSpeechSynthesizer(). It's working fine in iOS 9 but has the following error in iOS 10:

Could not get attribute 'LocalURL': Error Domain=MobileAssetError Code=1 "Unable to copy asset attributes" UserInfo={NSDescription=Unable to copy asset attributes}

Does anyone know what's going on here?

static let speechSynthesizer = AVSpeechSynthesizer()

static func speak(text: String) {
    if speechSynthesizer.isSpeaking {
        speechSynthesizer.continueSpeaking()
    } else {
        let speechUtterance = AVSpeechUtterance(string: text)

        speechUtterance.rate = 0.45 // 0.0 -> 1.0
        speechUtterance.pitchMultiplier = 1 // 0.5 -> 2.0
        speechUtterance.volume = 0.75 // 0.0 -> 1.0

        speechSynthesizer.speak(speechUtterance)
    }
}

The error occurs right after speechSynthesizer.isSpeaking called

来源:https://stackoverflow.com/questions/39842363/avspeechsynthesizer-errors-in-ios-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!