My understanding from the documentation is that an utterance will use the default voice for the current user locale but that does not appear to be the case or I am doing something wrong.
Is this the correct way to obtain the default system voice using AVSpeechSynthesizer or is the returned value incorrect?
If it matters, I am utilizing Big Sur, 11.4 but I am not getting the correct default voice. What I get back is coincidentally, the last voice in my accessibility voice list.
The default voice on my machine is currently "Kate".
When using NSSpeechSynthesizer.defaultVoice is get "Kate" as the listed default voice.
When using AVSpeechSynthesisVoice, the default voice returned is "Albert" which incorrect.
My language code is: en-US
let userCode = AVSpeechSynthesisVoice.currentLanguageCode()
let usedVoice = AVSpeechSynthesisVoice(language: userCode) // should be the default voice
let voice = NSSpeechSynthesizer.defaultVoice
print("userCode: \(userCode)")
print("NSSpeechSynthesizer: \(voice)")
print("AVSpeechSynthesisVoice: \(usedVoice)")
.
Result:
userCode: en-US
NSSpeechSynthesizer: NSSpeechSynthesizerVoiceName(_rawValue: com.apple.speech.synthesis.voice.kate.premium) <--- this is the correct system default
AVSpeechSynthesisVoice: Optional([AVSpeechSynthesisVoice 0x6000000051a0] Language: en-US, Name: Albert, Quality: Enhanced [com.apple.speech.synthesis.voice.Albert])