Skip to content
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

Enable whole-program optimization when compiling eSpeak-NG #17631

Merged

Conversation

gexgd0419
Copy link
Contributor

Link to issue number:

Closes #17623

Summary of the issue:

As for now, whole-program optimization for eSpeak-NG is intentionally turned off.

# Whole-program optimization causes eSpeak to distort and warble with its Klatt4 voice
# Therefore specifically force it off
"/GL-",

This was introduced in commit cf0443b when MSVC 2012 was used to compile eSpeak.

Enabling whole-program optimization can make the eSpeak DLL more efficient and smaller, from 637 KiB to 624 KiB.

It can also solve the problem of using a dynamically linked version of Sonic without __declspec(dllimport) in the header, because the optimization will be performed by the linker, if whole-program optimization is enabled.

Description of user facing changes

None.

Description of development approach

Enable whole-program optimization by removing the /GL- option.

Testing strategy:

I tried the klatt4 variant, but couldn't notice the difference between enabling and disabling the whole-program optimization. In fact, the waveforms generated are exactly the same.

Known issues with pull request:

None.

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:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@gexgd0419 gexgd0419 requested a review from a team as a code owner January 17, 2025 05:28
@gexgd0419 gexgd0419 requested a review from seanbudd January 17, 2025 05:28
@seanbudd
Copy link
Member

@gexgd0419 - did you test the klatt voice at different rates and while rateboosted?

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jan 20, 2025
@gexgd0419
Copy link
Contributor Author

I compared the waveforms by inverting one of them and overlay it onto the other to check if they could cancel each other out.

When at 1X speed, the waveforms could cancel each other out perfectly, leaving only silence, which means that they were exactly the same.

When using rate boost, however, the result wasn't purely silence, so the cancelling out wasn't perfect, which means that they were not exactly the same. But still, the result was much quieter, so the cancelling out did work to some extent, which means that they were at least very similar.

Here are two of the wave files I got from eSpeak, with rate boost enabled, one with and one without whole-program optimization. You can listen to them and compare them.

Welcome to NVDA dialog wave files (with rate boost).zip

I also tried making eSpeak speak the same thing twice at the same rate when it was compiled without whole-program optimization. But still, the results couldn't cancel each other out perfectly. I would assume that rate boosting the same audio might make it slightly different each time.

@seanbudd seanbudd merged commit 098863b into nvaccess:master Jan 21, 2025
5 checks passed
@github-actions github-actions bot added this to the 2025.1 milestone Jan 21, 2025
@gexgd0419 gexgd0419 deleted the espeak-enable-whole-program-optimization branch February 6, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable whole-program optimization when compiling eSpeak-NG
3 participants