mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[ios] Improved TTS system voice selection
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
c589aaa3cf
commit
1b8172f744
@@ -243,9 +243,24 @@ using Observers = NSHashTable<Observer>;
|
||||
|
||||
AVSpeechSynthesisVoice * voice = nil;
|
||||
for (NSString * loc in candidateLocales) {
|
||||
voice = [AVSpeechSynthesisVoice voiceWithLanguage:loc];
|
||||
if (voice)
|
||||
if (@available(iOS 16.0, *)) {
|
||||
for (AVSpeechSynthesisVoice * aVoice in [AVSpeechSynthesisVoice speechVoices]) {
|
||||
if (voice == nil && aVoice.language == loc && aVoice.quality == AVSpeechSynthesisVoiceQualityPremium) {
|
||||
voice = aVoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AVSpeechSynthesisVoice * aVoice in [AVSpeechSynthesisVoice speechVoices]) {
|
||||
if (voice == nil && aVoice.language == loc && aVoice.quality == AVSpeechSynthesisVoiceQualityEnhanced) {
|
||||
voice = aVoice;
|
||||
}
|
||||
}
|
||||
if (voice == nil) {
|
||||
voice = [AVSpeechSynthesisVoice voiceWithLanguage:loc];
|
||||
}
|
||||
if (voice) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.speechVoice = voice;
|
||||
|
||||
Reference in New Issue
Block a user