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

Add HUD #773

Merged
merged 18 commits into from Oct 19, 2021
Merged

Add HUD #773

merged 18 commits into from Oct 19, 2021

Conversation

dmakarov
Copy link
Contributor

@dmakarov dmakarov commented Mar 15, 2020

Title

HUD to display recognized utterances and corresponding actions

Description

This adds the HUD GUI. This is work in progress. Initial PR to reveal any possible issues.

Related Issue

Motivation and Context

It is hoped to improve the user experience.

How Has This Been Tested

Ran on macOS and Windows

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue or bug)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Renamed existing command phrases (we discourage this without a strong rationale).

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have checked that my code does not duplicate functionality elsewhere in Caster.
  • I have checked for and utilized existing command phrases from within Caster (delete if not applicable).
  • My code implements all the features I wish to merge in this pull request.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests pass.

Maintainer/Reviewer Checklist

  • Basic functionality has been tested and works as claimed.
  • New documentation is clear and complete.
  • Code is clear and readable.

@dmakarov
Copy link
Contributor Author

ScreenFlow

@LexiconCode LexiconCode added GUI issues related to graphics user interface New Feature A new feature that is not currently implemented. WIP An work in progress Python 3 Issues related to Python 3 labels Mar 15, 2020
@LexiconCode
Copy link
Member

It's been great coordinating chat make this possible! Thank you for your work on this as it's invaluable. Looking forward to testing!

_caster.py Outdated Show resolved Hide resolved
@kendonB
Copy link
Collaborator

kendonB commented Apr 30, 2020

This one isn't working for me with kaldi:

ERROR:action:Exception from function show_hud:
Traceback (most recent call last):
  File "C:\Python27_64\lib\site-packages\dragonfly\actions\action_function.py", line 145, in _execute
    self._function(**arguments)
  File "castervoice\lib\utilities.py", line 361, in show_hud
    hud.show_hud()
  File "C:\Python27_64\lib\xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27_64\lib\xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "C:\Python27_64\lib\xmlrpclib.py", line 1283, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27_64\lib\xmlrpclib.py", line 1311, in single_request
    self.send_content(h, request_body)
  File "C:\Python27_64\lib\xmlrpclib.py", line 1459, in send_content
    connection.endheaders(request_body)
  File "C:\Python27_64\lib\httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "C:\Python27_64\lib\httplib.py", line 882, in _send_output
    self.send(msg)
  File "C:\Python27_64\lib\httplib.py", line 844, in send
    self.connect()
  File "C:\Python27_64\lib\httplib.py", line 821, in connect
    self.timeout, self.source_address)
  File "C:\Python27_64\lib\socket.py", line 575, in create_connection
    raise err
error: [Errno 10061] No connection could be made because the target machine actively refused it
ERROR:action.exec:Execution failed: 'show_hud'(): [Errno 10061] No connection could be made because the target machine actively refused it
```

@dmakarov
Copy link
Contributor Author

@kendonB this requires python3.

@kendonB
Copy link
Collaborator

kendonB commented Apr 30, 2020

@dmakarov is the idea here that we'd hold off on merging this until natlink is up and running with python 3? Or this would just be available for people with Kaldi setups?

@dmakarov
Copy link
Contributor Author

dmakarov commented May 1, 2020

@kendonB as far as I know natlink works on python3. This PR is still WIP, but I should finish it soon. I didn’t intend HUD to be available only with kaldi engine, although I test it only with kaldi and test engines, and don’t know whether it would be useful with other setups. There’s nothing engine specific in HUD’s code though. Overall the idea was to consolidate all separate Caster’s GUI under one app and single RPC server.

def closeEvent(self, event):
event.accept()

def setup_xmlrpc_server(self):
Copy link

Choose a reason for hiding this comment

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

Apologies for the drive-by comment, but might this need a security token type of thing here, like what dragonfly & aenea use? https://github.com/dictation-toolbox/dragonfly/pull/61/files#diff-6219d462fba21473f0a2404097943f75R29

The danger case would be something like: user is tricked into browsing to evil website, evil website asks web browser to make xmlhttprequests to http://localhost:1338, evil website can now ask this server to execute any registered function. Obviously from a practical perspective this is only going to be a concern if a caster user is actively being targeted (and the blast radius in this server seems small right now - basically it'd be annoying to have the rules UI show up or have caster quit unexpectedly), but mentioning it here anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I will consider adding the security token. Probably, not in this PR, however.

Copy link
Collaborator

@kendonB kendonB May 1, 2020

Choose a reason for hiding this comment

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

Is adding the security token difficult? I wouldn't want any extra vulnerabilities introduced to master.

Copy link
Member

Choose a reason for hiding this comment

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

It's actually a vulnerability that exists already with the current implementation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The current master you mean? Can we fix that?

Copy link
Member

Choose a reason for hiding this comment

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

@kendonB That's correct and in the current master. Basically someone would have to set up a malicious website specifically for caster and a caster user would have to go to that website. In that case they then could control RPC commands that are defined. Mostly emulating mouse now this is none that I know of control keyboard input.

To protect against this a secret would be randomly generated and be used for authentication for the client/server to protect against such targeting.

dmakarov mentioned he would implement it in another pull request.

Copy link

Choose a reason for hiding this comment

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

Yes, sorry, I should have mentioned that this is an existing problem so it's not meaningfully worse than before (just a couple new commands available to an attacker - but none of them seem to allow arbitrary code execution).

Copy link
Collaborator

Choose a reason for hiding this comment

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

@caspark would you be able to open an issue on this (for the current vulnerabilities)?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the reminder @caspark
Documented in #809

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I will consider adding the security token. Probably, not in this PR, however.

Is this something you are willing to take on?

@LexiconCode

This comment has been minimized.

@LexiconCode LexiconCode mentioned this pull request Aug 3, 2021
17 tasks
@LexiconCode
Copy link
Member

This will work with everything but Python 32-bit 2.7.x. This is a limitation of QT 5 via pyside2. Really only affects DNS with Natlink on 32-bit 2.7.x.

@LexiconCode LexiconCode removed the Python 3 Issues related to Python 3 label Aug 5, 2021
- Redirect dragonfly observers and logging to printer.out
The RPC timeout with the hud can interfere with the dragonfly speech recognition loop. This appears as a stutter recognition latency. Exceptions are tracked so this stutter only happens to end user once. An exception occurs if the hud is not available/python 2/running text engine. If an exception in handle_message, print is managed by SimplePrintMessageHandler
- Removed LoggingHandler
- Re-factored RecognitionObserver to configure_engine.py
@bluecamel
Copy link

@dmakarov This is wonderful! FWIW, I made a couple of tweaks to help with when it was crashing caster.

@dmakarov still getting this error with python 3

I had this issue at first too. There was another error earlier from when the hud tried to start, but that was hitting a Shiboken error. I upgraded PyQt5 and PySide2 and it's working great now.

@LexiconCode
Copy link
Member

@dmakarov This is wonderful! FWIW, I made a couple of tweaks to help with when it was crashing caster.

@dmakarov still getting this error with python 3

I had this issue at first too. There was another error earlier from when the hud tried to start, but that was hitting a Shiboken error. I upgraded PyQt5 and PySide2 and it's working great now.

I've included some of your enhancements catching connection error. This PR will be merged Directly but will be included in a new all request combines most of dmakarov work and drop support for Python 2.

@LexiconCode LexiconCode changed the base branch from master to DropPy2 October 18, 2021 21:19
@LexiconCode LexiconCode merged commit eb803ed into dictation-toolbox:DropPy2 Oct 19, 2021
LexiconCode pushed a commit to LexiconCode/Caster that referenced this pull request Jan 14, 2022
LexiconCode pushed a commit to LexiconCode/Caster that referenced this pull request Feb 22, 2022
LexiconCode pushed a commit to LexiconCode/Caster that referenced this pull request Mar 10, 2022
bvancil pushed a commit to bvancil/Caster that referenced this pull request Dec 21, 2022
bvancil added a commit to bvancil/Caster that referenced this pull request Dec 21, 2022
commit a5303dd
Author: Brian Vancil <1388508+bvancil@users.noreply.github.com>
Date:   Wed Dec 21 16:40:34 2022 -0600

    Added vscode terminal pane toggle

commit 1de7195
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Sun Oct 30 08:25:03 2022 -0500

    Hud use TK and multiprocessing and Queue

commit 992fd88
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Tue Jul 5 13:50:08 2022 -0500

    add missing extras and defaults `Your_First_Rule.md` and example rules

commit e5f047f
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Mon Feb 14 03:54:59 2022 -0600

    Update collections import

commit bca040d
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Sat Feb 12 02:21:41 2022 -0600

    Clean up hud state

commit de91635
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Sat Feb 12 01:51:22 2022 -0600

    Only find DPI/DNS if isNatSpeakRunningnatlink.

commit 1ec2775
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Thu Feb 10 20:20:30 2022 -0600

    remove settings window manual path handling

commit d0c3cce
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Thu Feb 10 20:10:51 2022 -0600

    Rename WXTYPE_SETTINGS to QTTYPE_SETTINGS

commit bf2be01
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Thu Feb 10 19:41:21 2022 -0600

    removed availability_message function

    PIL is cross platform
    https://pillow.readthedocs.io/en/stable/installation.html

commit 556e6dc
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Thu Feb 10 19:27:35 2022 -0600

    remove wxpython

commit e821be9
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Thu Feb 10 19:05:28 2022 -0600

    Clear hud when restarting Caster

commit dd61366
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Tue Feb 8 15:23:04 2022 -0600

    "clear caster hud" command clears the "Caster: Status Window"  if hud is not available

commit e0a5b1d
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Tue Feb 8 15:21:32 2022 -0600

    Rename and add hud commands to docs

    - rename hud commands to be less ambiguous

commit d31fe8c
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Mon Jan 31 23:02:33 2022 -0600

    add PySide2 to windows os

commit f868f01
Author: Brian Vancil <1388508+bvancil@users.noreply.github.com>
Date:   Wed Dec 21 16:38:18 2022 -0600

    dragonfly2 version bump to 0.34.0

    - Fix various bugs with keyboard/text input actions on Windows
    - Fix problems caused by relative import statements in the library by using the absolute form instead.
    - edited by bvancil to resolve merge conflicts

commit 9e07efd
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Mon Jan 31 22:47:44 2022 -0600

    rename work flow

commit ec459fc
Author: Kendon Bell <kendonB@users.noreply.github.com>
Date:   Tue Jan 25 13:46:45 2022 +1300

    PySide2 version

    I got this error with an old PySide2 Manjaro-WebDad/jak#67

commit bdf04ca
Author: Kendon Bell <kendonB@users.noreply.github.com>
Date:   Fri Jan 21 11:20:33 2022 +1300

    update docs for keyboard

    Adding the "release modifier keys" command that replaced "release <keyname>"

commit 31d1e89
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Wed Jan 19 12:29:47 2022 -0600

    Remove API command grammars examples

commit 9c67920
Author: Dmitri Makarov <dmakarov@users.noreply.github.com>
Date:   Tue Oct 19 06:15:45 2021 -0700

    Convert HMC to QT on python 3 (dictation-toolbox#786)

commit 2e573c7
Author: Dmitri Makarov <dmakarov@users.noreply.github.com>
Date:   Mon Oct 18 17:19:10 2021 -0700

    Add HUD (dictation-toolbox#773)

commit 5dd65fb
Author: Brian Vancil <1388508+bvancil@users.noreply.github.com>
Date:   Wed Dec 21 16:31:28 2022 -0600

    utilized py launcher with explicit 3.8-32 python version

    -edited by bvancil to resolve merge conflicts

commit ded7e05
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Sun Oct 3 01:09:27 2021 -0500

    Miscellaneous cleanup

commit 1530d58
Author: Brian Vancil <1388508+bvancil@users.noreply.github.com>
Date:   Wed Dec 21 16:26:25 2022 -0600

    remove py2 action

    -edited by bvancil to remove merge conflicts

commit c4e0d28
Author: Brian Vancil <1388508+bvancil@users.noreply.github.com>
Date:   Wed Dec 21 16:23:08 2022 -0600

    remove imports for py2

    - remove default encoding utf-8 for py2
    - remove six code for py2
    - fix natlink imports for py3
    - edited by bvancil to resolve merge dependencies

commit c041a90
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Fri Oct 1 19:46:17 2021 -0500

    Drop py2 pathlib port

commit 2ed2487
Author: LexiconCode <CasterVoice@protonmail.com>
Date:   Fri Oct 1 19:02:43 2021 -0500

    Doc Natlink Py3
kendonB added a commit to kendonB/Caster that referenced this pull request Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI issues related to graphics user interface New Feature A new feature that is not currently implemented. Waiting For Issue/PR Another open issue/PR (in caster or upstream) must be completed before this can be addressed. WIP An work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants