iosswiftavspeechsynthesizer

Why is AVSpeechSynthesizer reproducing more information that my text?


I'm using AVSpeechSynthesizer for texts, here's relevant code.-

guard let nonNilText = text else { return }
let utterance = AVSpeechUtterance(string: nonNilText)
utterance.voice = AVSpeechSynthesisVoice(language: Locale.current.identifier)
utterance.rate = 0.4
synthesizer.speak(utterance)

Everything works fine, but seems that in some devices, particularly when the iPhone locale is set to English, voice over is reproducing what sounds like a description of the utterance itself: something like "Speak: rate xxx, voice name equals to com.apple..." before my text.

I'm guessing this might have to do with some accessibility setting, but can't figure out where to enable it to reproduce the issue on my iPhone. Any idea?.


Solution

  • What finally worked was just removing the line.-

    utterance.voice = AVSpeechSynthesisVoice(language: Locale.current.identifier)

    to let the synthesizer pick the voice itself.