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

Refactor more speech functions #10593

Merged
merged 18 commits into from Jan 29, 2020
Merged

Refactor more speech functions #10593

merged 18 commits into from Jan 29, 2020

Conversation

feerrenrut
Copy link
Contributor

@feerrenrut feerrenrut commented Dec 8, 2019

Link to issue number:

None

Summary of the issue:

Returning sequences from these functions allows us greater flexibility for affecting all speech that is caused by a call to speakObject.

Description of how this pull request fixes the issue:

Split several functions into a speakX and getXspeech

This PR maintains backwards compatibility

Testing performed:

Ran NVDA from source.

Known issues with pull request:

  • Todo: rename getSpeechForSpelling to getSpellingSpeech

Change log entry:

Section: New features, Changes, Bug fixes

@zstanecic

This comment has been minimized.

@michaelDCurran
Copy link
Member

michaelDCurran commented Dec 9, 2019 via email

@Brian1Gaff

This comment has been minimized.

@feerrenrut
Copy link
Contributor Author

@zstanecic and @Brian1Gaff This PR does not break backwards compatibility. The description has been updated to make that clear.

Copy link
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, however note that I only had to had time to look at the code briefly, I haven't tested this. I therefore recommend a look from @michaelDCurran before merging this.

source/speech/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@michaelDCurran michaelDCurran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Would it be possible to make a new type annotation for 'reason'? All through this code you have reason: str. It would be great if this could be its own type.
  • with all the speakSelection functions: it would be good if they could take speech sequences, rather than just strings. Then speakSelectionChange can pass in a sequence from getTextInfoSpeech rather than just TextInfo.text. It also means that some of the code in speakSelectionChange can be replaced with a call to getSpellingSpeech. However, these changes would mean we can't have the text included with the message as part of one translatable string. Though I don't believe this is a bad thing.

source/speech/__init__.py Outdated Show resolved Hide resolved
source/speech/__init__.py Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

  • PR introduces Flake8 errors

See test results for failed build of commit 4ee5ba34ef

@michaelDCurran
Copy link
Member

Is it just me, or have the changes to speech/__init__.py been lost in this pr?

@feerrenrut
Copy link
Contributor Author

feerrenrut commented Jan 14, 2020

Is it just me, or have the changes to speech/init.py been lost in this pr?

I think it's just you 😉. It is hidden from the diff initially because it is "large". You can jump to it, or other files by pressing 't' and typing __init__. A direct link to the file in the diff: https://github.com/nvaccess/nvda/pull/10593/files#diff-46301b9ce4a78abc208b3358db03e972

@feerrenrut feerrenrut added this to In progress in [Project] Speech Refactor via automation Jan 20, 2020
…Info

Clarify that the sequence is modified in place, nothing is spoken.
For now deprecate (but maintain) the old name.
For easier testing / refactoring.
Use instance methods directly.
Make speakWithoutPauses an instance method
- To make it more testable.
- Keep backwards compat; speakWithoutPauses name is added at module level.

Make getSpeechWithoutPauses a generator with return value.
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.

Add unit test for speechWithoutPauses
 - To ensure behavior has not changed between implementations
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.
Simplify the speakObject function by extracting this calculation into a
helper.
The new method '_objectSpeech_calculateAllowedProps()',
was extracted from 'speakObject()' and needs formatting
to pass linting checks.
Must flatten the results from getTextInfoSpeech generator.
Rename _speakPlaceholderIfEmpty -> _getPlaceholderSpeechIfTextEmpty
@feerrenrut
Copy link
Contributor Author

I'm going to rebase and merge this PR (to preserve the history of the refactor). I'll push after the rebase so that the commits in this PR / branch match.

feerrenrut added a commit that referenced this pull request Jan 29, 2020
Split several functions into two. One speakX acts as before, but relies
on a new getXspeech which returns a speech sequence.

This PR maintains backwards compatibility.

This branch is being merged to preseve history of the refactor.
Merge remote-tracking branch 'origin/refactorMoreSpeechFunctions'
@feerrenrut feerrenrut merged commit 9a884eb into master Jan 29, 2020
[Project] Speech Refactor automation moved this from In progress to Done Jan 29, 2020
@feerrenrut feerrenrut deleted the refactorMoreSpeechFunctions branch January 29, 2020 09:06
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jan 29, 2020
feerrenrut added a commit that referenced this pull request Jan 29, 2020
@seanbudd seanbudd added the deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release label Mar 5, 2021
seanbudd pushed a commit that referenced this pull request Mar 22, 2021
Removes code provided for backwards compatibility in PR #10593

### Summary of the issue:

PR #10593 introduced `speech.speakWithoutPauses ` as an alias for `speech._speakWithoutPauses.speakWithoutPauses` and `speech.re_last_pause` as an alias for `speech._speakWithoutPauses.re_last_pause` for backwards compatibility. Since 2021.1 is going to be backwards compatibility breaking release it makes sense to remove these.

### Description of how this pull request fixes the issue:

These aliases are removed and their usages are replaces with `speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses` and `speech.SpeechWithoutPauses.re_last_pause` respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release
Projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants