Skip to content

Add pre_filter_speechSequence and post_filter_speechSequence Action and use post_filter_speechSequence in speechViewer#16213

Closed
beqabeqa473 wants to merge 8 commits into
nvaccess:masterfrom
beqabeqa473:speech_viewer_use_filter_speechSequence
Closed

Add pre_filter_speechSequence and post_filter_speechSequence Action and use post_filter_speechSequence in speechViewer#16213
beqabeqa473 wants to merge 8 commits into
nvaccess:masterfrom
beqabeqa473:speech_viewer_use_filter_speechSequence

Conversation

@beqabeqa473
Copy link
Copy Markdown
Contributor

@beqabeqa473 beqabeqa473 commented Feb 22, 2024

Link to issue number:

None

Summary of the issue:

Add speechSequencePreFilter extensionPoint Action, inject it just before filter in speech.speak and use it in speechViewer as @LeonarddeR stated in #14520

Description of user facing changes

Nothing changed

Description of development approach

Removed code responsible for appending speechSequence to speech_viewer from speech.speak and registered appendSpeechSequence as extensionPoint handler function.

Testing strategy:

Manually tested that speech is still visible on the screen when activating speech_viewer

Known issues with pull request:

None at this moment

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.

@beqabeqa473 beqabeqa473 requested a review from a team as a code owner February 22, 2024 21:11
@seanbudd
Copy link
Copy Markdown
Member

I don't think using a filter function is appropriate in this case. appendSpeechSequence is an action, it doesn't filter the speech sequence.

@seanbudd
Copy link
Copy Markdown
Member

SpeechViewer should also be outputting the "final" speech. If speech is filtered after appendSpeechSequence, then speechViewer will not be accurate. This should rather use an Action extension point pre_speak or similar

@seanbudd seanbudd marked this pull request as draft February 22, 2024 22:19
@beqabeqa473
Copy link
Copy Markdown
Contributor Author

I don't think using a filter function is appropriate in this case. appendSpeechSequence is an action, it doesn't filter the speech sequence.

Yes, I understand that, but is it worth creating an action along with
a filter just to gett a speech sequence?

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

beqabeqa473 commented Feb 22, 2024

SpeechViewer should also be outputting the "final" speech. If speech is filtered after appendSpeechSequence, then speechViewer will not be accurate. This should rather use an Action extension point pre_speak or similar

Are you sure speechViewer is outputting final speech now? in the code
of speech.speak, appendSpeechSequence is called before any filtering.

@seanbudd
Copy link
Copy Markdown
Member

Are you sure speechViewer is outputting final speech now? in the code
of speech.speak, appendSpeechSequence is called before any filtering.

In master, filter_speechSequence.apply is called before appendSpeechSequence.
I believe other filtering further down in speech.speak happens by design after appendSpeechSequence. Is there anything you would expect to happen before appendSpeechSequence?

Yes, I understand that, but is it worth creating an action along with
a filter just to gett a speech sequence?

Well, the current code is fine as is, but if you want to use an extension point an action is more appropriate for the reasons outlined earlier.

…alled just before filterring

Make use of this new action in speechViewer instead of filter
@beqabeqa473 beqabeqa473 changed the title Use filter_speechSequence in speech_viewer Add speechSequencePreFilter Action and use it in speechViewer Feb 23, 2024
@beqabeqa473
Copy link
Copy Markdown
Contributor Author

Are you sure speechViewer is outputting final speech now? in the code
of speech.speak, appendSpeechSequence is called before any filtering.

In master, filter_speechSequence.apply is called before appendSpeechSequence. I believe other filtering further down in speech.speak happens by design after appendSpeechSequence. Is there anything you would expect to happen before appendSpeechSequence?

Yes, I understand that, but is it worth creating an action along with
a filter just to gett a speech sequence?

Well, the current code is fine as is, but if you want to use an extension point an action is more appropriate for the reasons outlined earlier.

I've added an extensionPoint Action which is notified just before filtering and used it in speechViewer.
I agree, that filtering is not the best way to go when we don't need to modify a speech.

@seanbudd
Copy link
Copy Markdown
Member

This approach seems off - it should be called after the filter extension point.

I don't really see a value in this change, as mentioned earlier, the code is fine as is.
Unless other consumers find the extension point useful, I wouldn't make this change.

@seanbudd
Copy link
Copy Markdown
Member

what problem is this PR trying to solve?

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

This approach seems off - it should be called after the filter extension point.

I don't really see a value in this change, as mentioned earlier, the code is fine as is. Unless other consumers find the extension point useful, I wouldn't make this change.

I don't understand, why speechViewer should get filtered text if in current master it is called before any filtering?
Maybe i am getting something wrong?

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

what problem is this PR trying to solve?

I don't think speech.speak is the correct place to have this code and i am not sure current approach is fine as is.
speech.speak is overloaded with unnecessary code which should go to their place, and registering a handler in speechViewer depending on logic the better than everytime importing it in speech.speak and doing unnecessary checks.

@XLTechie
Copy link
Copy Markdown
Collaborator

XLTechie commented Feb 23, 2024 via email

@LeonarddeR
Copy link
Copy Markdown
Collaborator

@seanbudd Note that a similar change has been performed for the Braille Viewer in #14503 , i.e. new extension points were made and the braille viewer has been changed to use them. To me, this pr makes perfect sense.

@CyrilleB79
Copy link
Copy Markdown
Contributor

@seanbudd, actually, the extension point provided in #16191 is a filter extension point. But as explained in #16191 (comment) and following, for some add-ons, an action point was enough.

It has been decided in #16191 that the filter could also act as an action point.
But if you feel more suitable to have two separate extension points for these two usages, this may provide a use case for this PR.

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

beqabeqa473 commented Feb 23, 2024 via email

@seanbudd
Copy link
Copy Markdown
Member

speech.speak is overloaded with unnecessary code which should go to their place,

This makes sense, though I would still use a post-filter action here.

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

speech.speak is overloaded with unnecessary code which should go to their place,

This makes sense, though I would still use a post-filter action here.

I have nothing against that, but in master, speechViewer appendSpeechSequence was always at the top in the speech.speak code, and changing it to postFilterAction could change expected behaviour.
Frankly speaking, i still cannot get a point in this. Do you want to change current behaviour? If yes, everything is clear for me in this case.

@XLTechie
Copy link
Copy Markdown
Collaborator

XLTechie commented Feb 23, 2024 via email

Comment thread source/speech/speech.py Outdated
Comment on lines -963 to -972
speechSequencePreFilter.notify(sequence=speechSequence)
speechSequence = filter_speechSequence.apply(speechSequence)
logBadSequenceTypes(speechSequence)
# in case priority was explicitly passed in as None, set to default.
priority: Spri = Spri.NORMAL if priority is None else priority

if not speechSequence: # Pointless - nothing to speak
return
import speechViewer
if speechViewer.isActive:
speechViewer.appendSpeechSequence(speechSequence)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please do not change the behaviour here, the extension point should be called where speechViewer.appendSpeechSequence is called

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should not be above here, we do not want to write empty sequences to speech viewer. this should not be below here, we still want to write speech to speech viewer with speech off.

Comment thread source/speech/extensions.py Outdated
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@AppVeyorBot
Copy link
Copy Markdown

See test results for failed build of commit d8d5ecbd68

@beqabeqa473
Copy link
Copy Markdown
Contributor Author

@seanbudd is it ok now?
While at it, i've added both pre and post filter actions to have more controll on speech from outside.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Mar 5, 2024
@seanbudd seanbudd marked this pull request as ready for review March 7, 2024 02:50
Copy link
Copy Markdown
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

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

Looks good to me, please add an item in the change log for changes for developers. Use a list for new extension points like in 2024.1.

Comment thread source/speech/speech.py Outdated
@beqabeqa473 beqabeqa473 changed the title Add speechSequencePreFilter Action and use it in speechViewer Add pre_filter_speechSequence and post_filter_speechSequence Action and use post_filter_speechSequence in speechViewer Mar 8, 2024
Comment thread projectDocs/dev/developerGuide/developerGuide.t2t
Comment thread projectDocs/dev/developerGuide/developerGuide.t2t
Comment thread source/speech/extensions.py
Comment thread projectDocs/dev/developerGuide/developerGuide.t2t
Comment thread source/speech/extensions.py
Comment thread source/speech/extensions.py
Comment thread source/speech/extensions.py
Comment thread source/speech/speech.py
import speechViewer
if speechViewer.isActive:
speechViewer.appendSpeechSequence(speechSequence)
post_filter_speechSequence.notify(sequence=speechSequence)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be after the speech mode checks (the if statements below it)?
If those trigger, nothing is spoken. Therefore nothing should appear in the viewer, nothing will have been spoken.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this has been discussed here before, but to recap this notification has to occur before checking what speech mode is active, to support the following use cases:

  • As a sighted tester who generally works with speech disabled I want to know what would have been spoken
  • As a Braille user I disable the speech, but want to see it on my Braille display in some cases (this, of course, will be possible only after Add abillity for braille to be tethered to speech #15898 is fixed)
  • If this extension point would be useful for a remote access solutions it is also important the notification is send even in cases in which the person accepting help disabled the speech, i.e. since they're sighted and find the fact that their computer talks during the remote session annoying.

In general there should be no change in logic here.

@seanbudd
Copy link
Copy Markdown
Member

@beqabeqa473 - do you intend to follow up to @XLTechie's suggestions?

@seanbudd
Copy link
Copy Markdown
Member

seanbudd commented Sep 1, 2024

Closing as abandoned

@seanbudd seanbudd closed this Sep 1, 2024
@seanbudd seanbudd added the Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. label Sep 1, 2024
@Adriani90
Copy link
Copy Markdown
Collaborator

cc: @hwf1324 you might find this interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. 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.

8 participants