Skip to content

Only strip from right of string when processing for symbol pronunciation and normalization is enabled#16786

Merged
seanbudd merged 4 commits into
nvaccess:betafrom
LeonarddeR:ocNormalized
Jul 2, 2024
Merged

Only strip from right of string when processing for symbol pronunciation and normalization is enabled#16786
seanbudd merged 4 commits into
nvaccess:betafrom
LeonarddeR:ocNormalized

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Jul 1, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #16772

Summary of the issue:

When reporting of normalized characters is enabled and OneCore is used, it does not pronounce the space that should be part of the speech sequence, so it announces Cnormalized rather than c normalized

Description of user facing changes

Normalized characters are pronounced correctly, e.g. as C normalized

Description of development approach

OneCore uses spelling functionality, which adds the character mode command to the speech sequence. This results in a sequence like [CharacterModeCommand(True), "C", CharacterModeCommand(False), " normalized"].
Every distinct string in the sequence is passed through ProcessText, which strips spacing from the left and right of the string. This effectively results in a string of Cnormalized passed to the synthesizer. Therefore, I changed processText to only strip from the right of the string when normalization is enabled.
Note that this bug is not related to the normalization code as such, the normalization work just uncovers an existing bug, which is now only fixed in the case of normalization.

Testing strategy:

Tested str from #16772

Known issues with pull request:

The underlying bug is still present when normalization is off. It would for example still apply if a translator translates the message for cap announcements: cap %s to something like %s cap. In that case, capital C would be announced as Ccap by OneCore.

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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved text processing by ensuring only trailing whitespaces are removed, preventing unintended removal of leading whitespaces.

@LeonarddeR LeonarddeR requested a review from a team as a code owner July 1, 2024 14:40
@LeonarddeR LeonarddeR requested review from seanbudd and removed request for a team July 1, 2024 14:40
@coderabbitai

coderabbitai Bot commented Jul 1, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The processText function in speech.py was modified to use text.rstrip() instead of text.strip(). This change impacts how trailing whitespaces are handled, ensuring that only trailing whitespace is removed rather than both leading and trailing whitespace.

Changes

File Change Summary
source/speech/speech.py Modified processText function to use text.rstrip() instead of text.strip()

Sequence Diagram(s)

N/A

Assessment against linked issues

Objective Addressed Explanation
Unicode normalization: Proper character pronunciation during navigation (#16772) Need to check if changing strip() to rstrip() handles normalization as required.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

cc @Adriani90

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 13ddf8f24e

Comment thread source/speech/speech.py Outdated
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jul 2, 2024
@seanbudd seanbudd added this to the 2024.3 milestone Jul 2, 2024
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@LeonarddeR LeonarddeR changed the title Only strip from right of string when processing for symbol pronunciation Only strip from right of string when processing for symbol pronunciation and normalization is enabled Jul 2, 2024
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

Great suggestion @seanbudd
I undid the changes to the changes file as this is now a fixup of the normalization code that doesn't touch normal behavior with normalization disabled.

@seanbudd seanbudd merged commit b4ef16f into nvaccess:beta Jul 2, 2024
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@coderabbitai could you open an issue for the known issue as provided in the summary?

@coderabbitai

coderabbitai Bot commented Jul 3, 2024

Copy link
Copy Markdown
Contributor

@LeonarddeR, the issue has been successfully created. You can view it here.

Analysis chain

@LeonarddeR, I will open an issue for the known issue as provided in the summary.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
gh issue create --title "OneCore does not pronounce spaces correctly when reporting normalized characters" \
--body "### Summary

When using OneCore with Unicode normalization enabled, NVDA fails to pronounce normalized characters correctly during character-by-character navigation. Specifically, it announces characters like \`C\` as \`Cnormalized\` without any pause, making it unclear to users. The expected behavior is to pronounce the character distinctly followed by the word \"normalized\", potentially with a short pause in between. This issue affects the readability and clarity of normalized characters for users.

### Relevant Information

- **PR:** https://github.com/nvaccess/nvda/pull/16786
- **Comment:** https://github.com/nvaccess/nvda/pull/16786#issuecomment-1662867366

### Steps to Reproduce

1. Enable Unicode normalization in NVDA.
2. Use OneCore as the speech synthesizer.
3. Navigate through text character by character.

### Expected Behavior

The character should be pronounced distinctly followed by the word \"normalized\" with a short pause in between.

### Actual Behavior

The character is pronounced as \`Cnormalized\` without any pause.

### Environment

- **NVDA version:** Latest
- **OneCore version:** Latest

### Additional Notes

This issue is a follow-up to the fix provided in PR #16786." \
--assignee "LeonarddeR"

Length of output: 1386

Actions performed

Comments resolved.

@CyrilleB79

Copy link
Copy Markdown
Contributor

@LeonarddeR wrote:

Known issues with pull request:

The underlying bug is still present when normalization is off. It would for example still apply if a translator translates the message for cap announcements: cap %s to something like %s cap. In that case, capital C would be announced as Ccap by OneCore.

This bug is confirmed in French, where "cap %s" is translated to "%s majuscule". The bug is very noticeable with "V" or "Z", a little less noticeable with other letters such as "C", where OneCore speaks something like "C MAjuscule". I have also tested with 2024.1 where it was already present. Though, from what I know, no one has ever complained of this bug.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@CyrilleB79 Thanks for confirming this. Could you please create an issue for this if is isn't there already? I really want to apply rstrip globally, though I agree that it shouldn't be done that way in 2024.3, but rather in 2024.4.

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.

4 participants