Here's how I'm doing it. So far so good.
-(void) MeTalkTPretty
{
if (@available(iOS 17.0, *)) {
[AVSpeechSynthesizer requestPersonalVoiceAuthorizationWithCompletionHandler:^(AVSpeechSynthesisPersonalVoiceAuthorizationStatus status) {
NSLog(@"AVSpeechSynthesis requestPersonalVoiceWCH returned %lu", (unsigned long)status);
if (status == AVSpeechSynthesisPersonalVoiceAuthorizationStatusAuthorized)
{
NSLog(@"Yippee! I can use personal voice");
// set this in case none of the voices are personal voice
voiceToUse = [AVSpeechSynthesisVoice voiceWithLanguage:AVSpeechSynthesisVoice.currentLanguageCode];
for (AVSpeechSynthesisVoice *thisVoice in [AVSpeechSynthesisVoice speechVoices])
{
if (thisVoice.voiceTraits == AVSpeechSynthesisVoiceTraitIsPersonalVoice)
{
voiceToUse = [AVSpeechSynthesisVoice voiceWithIdentifier:thisVoice.identifier];
NSLog(@"WINNER is personal voice %@ ", voiceToUse);
}
}
}
else
{
NSLog(@"darn, I can't use personal voice even though on iOS17");
voiceToUse = [AVSpeechSynthesisVoice voiceWithLanguage:AVSpeechSynthesisVoice.currentLanguageCode];
}
}];
}
else {
NSLog(@"Darn, I can't use personal voice because this device isn't running ios17");
voiceToUse = [AVSpeechSynthesisVoice voiceWithLanguage:AVSpeechSynthesisVoice.currentLanguageCode];
}
}
Topic:
App & System Services
SubTopic:
Core OS
Tags: