XCode 8.2.1, Swift 3, iOS 10.0, iPhone 6s
I use this code for AVSpeechSynthesizer
private func listenText(text: String, language: String) { let speechLanguage: String = STTLanguagesManager.shared.getAppleLanguageWithCode(code: language); stopListening(); let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSessionCategoryPlayback) try audioSession.setMode(AVAudioSessionModeDefault) try audioSession.setActive(true, with: .notifyOthersOnDeactivation) } catch { print("audioSession properties weren't set because of an error.") return; } let synthUtterance = AVSpeechUtterance(string: text); synthUtterance.rate = currentSpeechRate; synthUtterance.voice = AVSpeechSynthesisVoice(language: speechLanguage); synthesizeEngine = AVSpeechSynthesizer(); synthesizeEngine!.speak(synthUtterance);}private func stopListening() { if (self.synthesizeEngine != nil && self.synthesizeEngine!.isSpeaking) { self.synthesizeEngine!.stopSpeaking(at: .immediate); } self.synthesizeEngine = nil;}Sometimes when I change language synthesizer doesn't speak anything. I noticed it is true for Chinese and Arabic languages.
I implemented AVSpeechSynthesizerDelegate and when I have this problem synthesizer fired didStart and didFinish delegates, without willSpeakRangeOfSpeechString.
How can I fix it?