I have a Text to Speech App and all is good, but I was looking for a voice.
In Settings/Accessibility/Voice Over/Speech/Voice there is a list of voices. I wanted to select one of those, for example "Susan (Enhanced)". How would I go about doing that?
I am new to Text to Speech and AVSpeechSynthesizer so I was hoping for some advice how to select that voice?
When I try it in General/Settings it sounds good, but when I select, what I thought was that voice it in my App, it sounds different. This happens with all of the voices I tried.
Here is the code I used to speak the text:
    for voice in AVSpeechSynthesisVoice.speechVoices()
    {
        print("\(voice.name)")
        if voice.name == "Susan (Enhanced)" {
            self.voiceToUse = voice
        }
    }
    let textToSpeak = self.tvTextToSpeak.text
    if (!textToSpeak!.isEmpty)
    {
        let speechSynthesizer = AVSpeechSynthesizer()
        let speechUtterance: AVSpeechUtterance = AVSpeechUtterance(string: textToSpeak!)
        speechUtterance.voice = self.voiceToUse
        speechSynthesizer.speak(speechUtterance)
    }
So if I use the same text as the example in the iOS settings it sounds different in my App, why?
Thanks for any clarification.
Many of the voices, especially the "enhanced" ones, need to be downloaded on the device first. On your device go to Settings->Accessibility->Spoken Content->Voices, and make sure that you download the voice that you're trying to use.
I was able to use "Samantha (Enhanced)", once I downloaded it.
Set speechUtterance.prefersAssistiveTechnologySettings = true to use Spoken content selected voice in your iPhone. And you don't need to specify what voice to use in this case.
A Boolean that specifies whether assistive technology settings take precedence over the property values of this utterance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With