mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03: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,10 +243,25 @@ using Observers = NSHashTable<Observer>;
|
|||||||
|
|
||||||
AVSpeechSynthesisVoice * voice = nil;
|
AVSpeechSynthesisVoice * voice = nil;
|
||||||
for (NSString * loc in candidateLocales) {
|
for (NSString * loc in candidateLocales) {
|
||||||
|
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];
|
voice = [AVSpeechSynthesisVoice voiceWithLanguage:loc];
|
||||||
if (voice)
|
}
|
||||||
|
if (voice) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.speechVoice = voice;
|
self.speechVoice = voice;
|
||||||
if (voice) {
|
if (voice) {
|
||||||
|
|||||||
Reference in New Issue
Block a user