AVSpeechSynthesizer errors in iOS 10

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}

  • Swift 3 Local notifications not firing
  • Xcode 8.0 CBCentralManager Issue
  • Detecting GSM Call States in IOS 10 (Swift 3, Xcode 8) and Notification from Background state
  • PresentScene only working without transition over a collection view
  • Request authorization to Media Library programmatically fails
  • iOS 11 Navigation TitleView misplaced
  • 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