Skip to content

fix: prefer premium/enhanced voices over compact in Apple TTS#1117

Merged
tisfeng merged 5 commits intotisfeng:devfrom
Jack-Xiao:fix/apple-tts-prefer-higher-quality-voices
Mar 20, 2026
Merged

fix: prefer premium/enhanced voices over compact in Apple TTS#1117
tisfeng merged 5 commits intotisfeng:devfrom
Jack-Xiao:fix/apple-tts-prefer-higher-quality-voices

Conversation

@Jack-Xiao
Copy link
Copy Markdown
Contributor

Summary

Fixes #1116

voiceIdentifier(for:) previously returned the compact (lowest quality) voice immediately, ignoring any Enhanced or Premium voices the user may have downloaded via System Settings.

Changes

  • Collect all matching voices for the locale in a single pass
  • Rank by quality: premium (2) > enhanced (1) > others including compact (0)
  • Return the highest-ranked voice
  • Removes the redundant second loop

Before / After

Before: always returns compact voice first, ignores downloaded Enhanced/Premium voices.

After: prefers premiumenhancedcompact/others. The hardcoded fallback "com.apple.voice.compact.en-US.Samantha" is intentionally kept — compact is always pre-installed and serves as a safe last resort when no voice is found for the locale.

Test plan

  • With no Enhanced/Premium voices installed: verify compact voice is still used
  • With Samantha (Enhanced) downloaded: verify enhanced voice is selected over compact
  • With a Premium voice downloaded: verify premium voice is selected over enhanced

Previously, voiceIdentifier(for:) always returned the compact (lowest
quality) voice first, ignoring any Enhanced or Premium voices the user
may have downloaded via System Settings.

Now collects all matching voices for the locale and picks the highest
quality one: premium (2) > enhanced (1) > others including compact (0).
The two-pass loop is also simplified into a single pass.

Fixes tisfeng#1116
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Jack-Xiao, Thank you for your first PR contribution 🎉 Jack-Xiao

@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Mar 15, 2026

Thanks your PR, we will review it later

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Apple TTS voice selection to prefer higher-quality system voices for a given language/locale.

Changes:

  • Collects all voices matching the target locale and assigns a quality-based priority.
  • Selects the highest-priority voice (premium > enhanced > others) instead of preferring compact voices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Easydict/Swift/Service/Apple/AppleSpeechService/AppleSpeechService.swift Outdated
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Mar 18, 2026

This change isn’t ideal. I tested an English sentence, and it uses “com.apple.speech.synthesis.voice.Albert” as the bestVoice. Albert is a quirky‑sounding voice, which isn’t suitable for general‑purpose TTS.

image

tisfeng added 2 commits March 19, 2026 01:54
Update Apple speech voice selection to rank premium, enhanced, then compact voices so playback falls back to compact instead of Eloquence or novelty voices.

Add unit tests for the voice priority rules and register the new test file in the project.
Reflow the content-type mismatch conditions and the response data binding in stream result updates without changing behavior.
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Mar 18, 2026

I have fixed this issue in 1ba6f8a

Currently, the voice selection strategy is: premium > enhanced > compact, using compact as a fallback.

@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Mar 18, 2026

Please review, if no problem, i will merge it

@Jack-Xiao
Copy link
Copy Markdown
Contributor Author

Thanks for the update. I reviewed the latest changes and they look good to me. The premium > enhanced > compact > others strategy makes sense, and the added tests cover the main cases well. No further issues from my side, feel free to merge it.

Copy link
Copy Markdown
Owner

@tisfeng tisfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

@tisfeng tisfeng merged commit 6b004ba into tisfeng:dev Mar 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Apple TTS should prefer Enhanced/Premium voices over Compact voices

3 participants