Skip to content

Add automatic language switching support for SAPI5 voices#17156

Merged
seanbudd merged 5 commits into
nvaccess:masterfrom
gexgd0419:sapi5-langchangesupport
Sep 16, 2024
Merged

Add automatic language switching support for SAPI5 voices#17156
seanbudd merged 5 commits into
nvaccess:masterfrom
gexgd0419:sapi5-langchangesupport

Conversation

@gexgd0419

@gexgd0419 gexgd0419 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor

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 the 0x prefix (e.g. 409 for English US), so here languageHandler is 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:

  • Have some SAPI5 voices in different languages installed.
  • Select an SAPI5 voice, and enable Automatic language switching.
  • Use an HTML with language attributes to test it. For example:
<html><body>
<p lang="zh-CN">This should be spoken with a Chinese voice.</p>
<p lang="en">This should be spoken with an English voice.</p>
</body></html>

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:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered: (no UI change)
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons. (API not changed)
  • Security precautions taken.

@coderabbitai summary

@gexgd0419 gexgd0419 marked this pull request as ready for review September 11, 2024 08:13
@gexgd0419 gexgd0419 requested a review from a team as a code owner September 11, 2024 08:13
@gexgd0419 gexgd0419 requested a review from seanbudd September 11, 2024 08:13
@gexgd0419 gexgd0419 marked this pull request as draft September 11, 2024 09:18
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 5e5ee3a871

@seanbudd seanbudd merged commit ff43dda into nvaccess:master Sep 16, 2024
@github-actions github-actions Bot added this to the 2025.1 milestone Sep 16, 2024
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.

Automatic language switching does not work for SAPI 5 voices

3 participants