-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Essentials: Text to speech] Overwrite system default voice #31105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: net10.0
Are you sure you want to change the base?
[Essentials: Text to speech] Overwrite system default voice #31105
Conversation
system default voice with ios/macos/androids
@dotnet-policy-service agree |
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
@MartyIX Anything else that I need to do for this PR to get approved? |
A member of the MAUI team must review this PR. I just help with review when I have a bit of time. Friendly ping @jfversluis |
@@ -30,7 +30,7 @@ static AVSpeechUtterance GetSpeechUtterance(string text, SpeechOptions options) | |||
{ | |||
// null voice if fine - it is the default | |||
speechUtterance.Voice = | |||
AVSpeechSynthesisVoice.FromLanguage(options.Locale?.Language) ?? | |||
AVSpeechSynthesisVoice.FromIdentifier(identifier: options.Locale?.Id) ?? // select the voice by identifier else set for default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a breaking change because people will set the Language property in their app now and then suddenly that stops working because they need to use the Id?
I'm wondering about the backwards compatibility of these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh.. That's right
speechUtterance.Voice = options.Locale?.Id != null ? AVSpeechSynthesisVoice.FromIdentifier(options.Locale.Id) : AVSpeechSynthesisVoice.FromLanguage(options.Locale?.Language) ?? AVSpeechSynthesisVoice.FromLanguage(AVSpeechSynthesisVoice.CurrentLanguageCode);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jfversluis thank you so much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any further update on this review?
This makes the project a lot more meaningful for users to change the Voice setting within the maui app.
/azp run |
Commenter does not have sufficient privileges for PR 31105 in repo dotnet/maui |
@MartyIX Can you help with this? |
I don't have a permission to run azp. @jfversluis Could you run tests please? |
/azp run MAUI-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-DeviceTests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
I download the artifacts from MAUI-Public. Updated the reproduction project with .net 10 preview. Added the downloaded nuget package. Tried on a macOS build. Will try on iOS and Android. |
@jfversluis Thank you for all the azp checks. |
UI tests are not useful for this, there are no UI tests that will cover this since its not a UI functionality :) Let me know your test results. I'm particularly interested in the backwards compatible scenario. If I have this implemented in my MAUI app today and update to .NET 10, I want to have no change in behavior or code unless I enable something extra. Can't promise I will still add this in before then, I'm kinda on the fence about it, but let's see if we can make it happen. |
Test on macOS: `var selectedLocale = locales.FirstOrDefault(locale => locale.Language == selectedLanguage); var speechOptions = new SpeechOptions { await TextToSpeech.Default.SpeakAsync($"Hello! I am {selectedVoice}. This is a Test! Ceci est un test! ¡Esto es una prueba! هذه تجربة!", speechOptions); ` |
ScreenRecording_08-29-2025.23-58-18_1.movartifacts from MAUI-Public on iOS |
Tested on Android. The GetLocalesAsync() returns all the voices as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jfversluis,
This is the latest commit that handle the backwards compatible scenario for ios.tvos.watchos.cs file
system default voice with ios/macos/androids
Note
Are you waiting for the changes in this PR to be merged? Yes
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
For ios/macos, AVSpeechSynthesisVoice.FromIdentifier is added together with FromLanguage. The Locale.Id can now be used along with Locale.Language.
For Android,
Get Locale is based on TTS voices and returns the Locale with their corresponding IDs instead of a Empty value.
tts.Voice is added for when option for speaksync is called with the Locale and its ID
Issues Fixed
Fixes #26853