A requirement of my application is to implement TTS. I can use the following code to loop through the available voices and select one. However, all of the available system voices are very low quality. There are no “(Enhanced)” version of the voices available. As I understand it, those are only on the device if the user has previously downloaded and configured it in their system settings.
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
if voice.language == "en-US" {
print("Language: (voice.language), Name: (voice.name)")
}
}
let desiredVoice = voices.first { $0.name == "Samantha" }
let utterance = AVSpeechUtterance(string: dictionaryEntry.word)
utterance.voice = desiredVoice
Self.synthesizer.speak(utterance)
Voices available on device by default (showing for “en-US”):
Language: en-US, Name: Trinoids
Language: en-US, Name: Albert
Language: en-US, Name: Jester
Language: en-US, Name: Samantha
Language: en-US, Name: Whisper
Language: en-US, Name: Superstar
Language: en-US, Name: Bells
Language: en-US, Name: Organ
Language: en-US, Name: Bad News
Language: en-US, Name: Bubbles
Language: en-US, Name: Junior
Language: en-US, Name: Bahh
Language: en-US, Name: Wobble
Language: en-US, Name: Boing
Language: en-US, Name: Good News
Language: en-US, Name: Zarvox
Language: en-US, Name: Ralph
Language: en-US, Name: Cellos
Language: en-US, Name: Kathy
Language: en-US, Name: Fred
How can I download and package a higher quality voice with my app to always use that voice when doing TTS?
If that is not possible using AVSpeechSynthesizer()
, are there alternative Swift libraries that can achieve this goal?