Add automatic language switching support for SAPI5 voices#17156
Merged
Conversation
See test results for failed build of commit 5e5ee3a871 |
seanbudd
approved these changes
Sep 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #17146
Summary of the issue:
Automatic language switching does not work for SAPI 5 voices, because the SAPI5 synth driver does not support
LangChangeCommand. This is a simple fix that uses the SAPI5<lang>tags to make the SAPI5 framework switch to a voice in the specified language.Description of user facing changes
Automatic language switching is enabled by default, so users who have SAPI5 voices in multiple languages may notice the voice switching after this change. As Microsoft Speech Platform voices use the same implementation, they will be affected as well.
Description of development approach
The SAPI5
<lang>tag requires a language ID in hexadecimal, without the0xprefix (e.g. 409 for English US), so herelanguageHandleris imported to do the language-to-LCID conversion. The text will be wrapped in a<lang langid="409">...</lang>XML tag, or if there's no valid corresponding LCID, the<lang>tag is removed to restore the original voice.Testing strategy:
I only tested it with some built-in SAPI5 voices, such as "Microsoft Huihui Desktop" and "Microsoft Zira Desktop". As there are many SAPI5 voices and Microsoft Speech Platform voices, more tests should be done.
Known issues with pull request:
SAPI5 voice switching may not be as fast as the OneCore voices.
Code Review Checklist:
@coderabbitai summary