Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 13 12:43
    Danesprite labeled #357
  • Sep 13 12:43
    Danesprite assigned #357
  • Sep 13 12:43
    Danesprite opened #357
  • Sep 13 12:29

    Danesprite on doc-changes

    (compare)

  • Sep 13 12:29

    Danesprite on master

    Make mention of AGPL v3 license… Merge pull request #356 from di… (compare)

  • Sep 13 12:29
    Danesprite closed #356
  • Sep 13 12:29
    Danesprite closed #355
  • Sep 12 13:27
    Danesprite labeled #356
  • Sep 12 13:27
    Danesprite labeled #356
  • Sep 12 13:27
    Danesprite opened #356
  • Sep 12 13:27
    Danesprite assigned #356
  • Sep 12 13:22

    Danesprite on doc-changes

    Make mention of AGPL v3 license… (compare)

  • Sep 12 12:53
    Danesprite commented #355
  • Sep 12 12:28
    Danesprite commented #355
  • Sep 12 12:16
    Danesprite assigned #355
  • Sep 12 12:16
    Danesprite labeled #355
  • Sep 12 12:16
    Danesprite labeled #355
  • Sep 08 05:04
    Danesprite commented #354
  • Sep 07 09:17
    Danesprite commented #354
  • Sep 07 09:12
    Danesprite labeled #354
Rebecca Stevenson
@rebeccaFste_twitter
@Danesprite, that does the trick, thank you! I just started using the _bringme module a few weeks ago and it makes life so much easier. Glad to have the folder functionality working
1 reply
Rebecca Stevenson
@rebeccaFste_twitter
@LexiconCode , oh wow thank you! I found one bare-bones module here (https://github.com/haughki/MyDragonflyModules/blob/master/slack.py) but I suspect my real issue might be that some kind of built-in shortcut in slack is interacting with my set up and messing things up (it always does unexpected things e.g selecting the menu etc). I guess I can deactivate my current grammars one at a time to try to track down the culprit, if that makes sense.
@shervinemami, I use Windows. As I mentioned above, I just started using _bringme and it is pretty magical. Highly recommended
MeteorVsBunny
@MeteorVsBunny

the commands in that grammer do not really look like slack to me
I have a slack grammar but I am using caster rather than dragonfly so if I shared the whole file it would not work for you. And I'm not familiar with setting up dragonfly only files
I replaced the commands in that file with my own, which should work but I have not tested it
control slash in Slack brings up the list of shortcuts so you can map any commands you want

from dragonfly import (Grammar, AppContext, MappingRule, Integer, Key, Text, Dictation, Repeat)
from supporting import utils

class SlackMapping(MappingRule):
mapping = {
"next [message]": Key("as-down"),
"prior [message]": Key("as-up"),
"open channel": Key("c-k"),
"next channel [<n>]": Key("a-down/15") Repeat(extra="n"),
"prior channel [<n>]": Key("a-up/15")
Repeat(extra="n"),
"keyboard": Key("c-slash"),
"info": Key("cs-i"),
"jump": Key("c-j"),
"attach file": Key("c-u"),
"edit last [message]": Key("c-up"),
"code block": Key("cas-c"),
"quit slack": Key("c-q"),

}
extras=[
    Integer("n", 1, 50),
    Integer("number", 1, 9999),
    Dictation("text"),
]
defaults = {
    "n": 1,
}

context = AppContext(executable="slack")
slack_grammar = Grammar("Slack Grammar", context=context)
slack_grammar.add_rule(SlackMapping())
slack_grammar.load()

def unload():
global slack_grammar
slack_grammar= utils.unloadHelper(slack_grammar, name)

Rebecca Stevenson
@rebeccaFste_twitter
@MeteorVsBunny thanks! I now have a functioning grammar
Rebecca Stevenson
@rebeccaFste_twitter
I also think I figured out which of my other grammars was screwing things up – it seems like the "release" function in multiedit somehow selects the menu in the upper left corner. No idea why. Not sure how to get around this. I tried just getting rid of the "release +" part preceding Key() but it seems "release" is maybe built into the grammar (i.e. line 268 here: https://github.com/t4ngo/dragonfly-modules/blob/master/command-modules/_multiedit.py).
Rebecca Stevenson
@rebeccaFste_twitter
Or something else in multiedit is causing the issue… Not sure it is "release"
David Zurow
@daanzu
@rebeccaFste_twitter I think some apps can do weird things when you release a key that wasn't actually being held, especially the modifier keys
samVanDerStoop
@samVanDerStoop
Im building some commands based on Utter Command's Human-Machine Grammar in dragonfly myself, but I could use some help. I want to avoid accidental command use in free dictation by avoiding one word commands (min two words) while also keeping utterances short, so I dont mind saying "one left" instead of just "left" to move a cursor. But I would like to be able to combine commands so that I can say "left backspace" instead of "one left one backspace", anyone have a good idea of how to have "1" be the default optional value in continous combined commands but have it be non-optional and required for single action commands?
LexiconCode
@LexiconCode

I also think I figured out which of my other grammars was screwing things up – it seems like the "release" function in multiedit somehow selects the menu in the upper left corner. No idea why. Not sure how to get around this. I tried just getting rid of the "release +" part preceding Key() but it seems "release" is maybe built into the grammar (i.e. line 268 here: https://github.com/t4ngo/dragonfly-modules/blob/master/command-modules/_multiedit.py).

There are some comments in the code that you might experiment with related to releasing the keys https://github.com/dictation-toolbox/dragonfly/blob/0a0eae5668baa0f5953972d5c9b5692f6c246309/dragonfly/actions/action_key.py. One thing I would recommend experimenting with is adding a pause before In and see it makes any difference sometimes there's timing issues. Rather than releasing X modifier you could really release all modifier keys without issues. Key("shift:up, ctrl:up, alt:up, win:up").execute() makes it a bit simpler instead of keeping track for every key that's been pressed.

Rebecca Stevenson
@rebeccaFste_twitter
Thanks @LexiconCode ! I'll give that a try. It also occurred to me that I could just switch to using slack on my browser which seems to work great :-)
LexiconCode
@LexiconCode

anyone have a good idea of how to have "1" be the default optional value in continous combined commands but have it be non-optional and required for single action commands?

I would also be curious in this as well as I hope to migrate the Caster repository leveraging Kim's method Utter Command's Human-Machine Grammar. However I don't think it's possible to do that dynamically.

timoses
@timoses:matrix.org
[m]
How to use alternative dictation in kaldi with another model?
Apparently one can pass a callback function as the alternative dictation method. How would that callback look using another kaldi model?
Would it be a second KaldiEngine object?
David Zurow
@daanzu
@timoses:matrix.org You would use kaldi-active-grammar directly, using a PlainDictationRecognizer instance
@timoses:matrix.org If you're feeling experimental, try plugging in https://github.com/daanzu/wav2vec2_stt_python
hakan ergin
@hakanErgin
hi, how can i press numpad slash button in a custom rule?
edit: nevermind, its npdiv (didnt see :))
LexiconCode
@LexiconCode
python -m dragonfly load _*.py --engine kaldi --engine-options " \ auto_add_to_user_lexicon=False"
usage: python -m dragonfly load [-h] [-e ENGINE] [-o ENGINE_OPTIONS]
                                [--language LANGUAGE] [-n]
                                [--no-recobs-messages]
                                [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-q]
                                [file [file ...]]
python -m dragonfly load: error: argument -o/--engine-options: invalid _engine_options_string value: ' \\ auto_add_to_user_lexicon=False'
Does not work either --engine-options "auto_add_to_user_lexicon=False"
I'm assuming there's some difference between Windows and Linux here. If so that does need to be documented.
Dane Finlay
@Danesprite
Is this with Python 2.7?
2 replies
Dane Finlay
@Danesprite
I've released dragonfly2 version 0.32.1, which includes fixes for various keyboard input bugs. You can upgrade with the following command:
pip install --upgrade dragonfly2
tripfish
@tripfish
:+1:
samVanDerStoop
@samVanDerStoop

Im trying to write a dragonfly command using a function with the clipboard toolkit but Im having some trouble. I want to 1) backup whatever is already on the clipboard 2) copy a new line of text that my cursor is in to the clipboard to read and manipulate it (print for now) 3) then return original backed up content to system clipboard. I tried to use the examples in the docs, but these wont work:

    original = Clipboard(from_system=True)
    print(original.get_system_text())

    Key("home, s-down, c-c").execute() # fails override system clipboard
    clipboard = Clipboard(from_system=True)  # Retrieve from system clipboard.
    current_line = clipboard.get_system_text()
    print(current_line)

    original.copy_to_system()

Weirdly enough, this seems to work every other time, it fails, works, then fails again. Or so it seems to me:

    original = Clipboard(from_system=True)
    print(original.get_system_text())

    clipboard = Clipboard()        # Create empty instance.
    Key("home, s-down, c-c").execute() # mostly fails to override system clipboard
    clipboard.copy_from_system()   # Retrieve from system clipboard.
    current_line = clipboard.get_system_text()
    print(current_line)

    original.copy_to_system()
Alex Boche
@alexboche
@samVanDerStoop I don't have a direct answer to your question atm, but this is the sort of functionality that was developed a lot in Caster docs, code. You may want to build on some of that.
samVanDerStoop
@samVanDerStoop
@alexboche Interesting, Im definitely going to dive into Caster at some point. For now I would like to build a good understanding of the more basic dragonfly buildingblocks. I think having a solid grasp of those will help in the proces of tweeking such (Caster) grammars and building my own later on
LexiconCode
@LexiconCode
@samVanDerStoop this is tricky. Understand that the clipboard was never meant to be a buffer. However outside of accessibility APIs it's the most accessible solution. There are number different types of timing issues working with the clipboard. Primarily applications can have different timings depending on how they interact with clipboard. In addition only one application can access the clipboard at once. Experiment adding pauses before and after different parts of your code.
there's been some enhancements made to dragonfly's clipboard class I have not take advantage in the following but it does work. https://github.com/dictation-toolbox/Caster/blob/d03ccd49ef3843a35bf2d2b60a732cd9a9521a40/castervoice/lib/context.py#L107
samVanDerStoop
@samVanDerStoop
@LexiconCode I see. Ive been looking through the read_selected_without_altering_clipboard function in your link. Can you explain why you use Clipboard directly when retrieving system_text in the first line of loop (prior_content = Clipboard.get_system_text()) instead of the specific instance cb with from_system=True (cb = Clipboard(from_system=True)) created earlier? Also should I always set the system_text to an empty string (Clipboard.set_system_text("")) before trying to overwrite clipboard contents? What does that do? Thanks for the help!
LexiconCode
@LexiconCode
@samVanDerStoop I didn't originally write those classes. I'm not sure why the original author didn't use the single instance of cb. I believe get_system_text is utilized because it's used as a comparison checking against the temporary contents which is also text in line 144 prior_content == temporary. Some enhancements in the last couple months to dragonfly's clipboard class now allows comparing clipboard instances.
Dane Finlay
@Danesprite
@samVanDerStoop You may find the synchronized_changes() and wait_for_change() methods added in version 0.32.0 helpful for what you're trying to do. They are documented on this page and are the enhancements Aaron alluded to above.
samVanDerStoop
@samVanDerStoop
@Danesprite @LexiconCode Awesome, Ill look into those!
Dane Finlay
@Danesprite
:+1:
samVanDerStoop
@samVanDerStoop
@Danesprite Ive had success using the methods. Thanks.
Dane Finlay
@Danesprite
@samVanDerStoop Great!
Quintijn Hoogenboom
@quintijn
Hi @samVanDerStoop , I have been working in the past period on the clipboard class as well, and we probably made some duplicates in our versions of the code. My intention, also discussed with @LexiconCode, was to move this module in the new repository dtactions (in the dictation-toolbox). Would you be so kind in having a look in that code too, and see how we can make a better module out of this? My working power on natlink/python is limited at the moment, because I am a little "over worked", is this sensible English?
The unittesting is also stuck, because I tried to open and close windows with autoHotkey actions, in order to be able to test completely separate from a speech engine. Also the autoHotkey functions (ahkBringup especially) looked very bright at the start, but caused me a lot of trouble. So also that part is possibly a task for some volunteer to pick up.
samVanDerStoop
@samVanDerStoop
@quintijn I would help if I could, but I'm certainly not at the required skill level. I'm doing what I can with python/dragonfly as a stepping stone to starting a study in programming/development, which I haven't yet at all, and have no other prior experience. As a beginner that's only just getting started everything is still new to me, and I would be more likely to break code than help improve it. I do hope my skills will grow so I can one day help contribute! All the work you lot put into this is inspiring.
Eric Paulson
@Versatilus
Sometimes you have to break things to figure out how they work. :-)
westocl
@westocl

I am using WSR and am using loading multiple grammars. What I am seeing is different behavior depending on the order of when the grammars are loaded. For example I load 4 grammars. When I load the ApiContextGrammar after the SignalAssignmentGrammar, then the ApiContextGrammar works properly and the SignalAssigmentGrammar doesnt. (Meaning recognitions are handled as expected) However I flip flop the order then the converse is true. It 'seems' as if there may be come coupling, and the final grammar loaded seems to win?

MicrophoneStatusGrammar.load()
SignalAssignmentGrammar.load()
ApiContextGrammar.load()
SpecialOperationGrammar.load()

Has Is this normal behavior.

westocl
@westocl
Hmmm... definitely somethin weird. It seems if I were to import all of the rules into one grammar and load only one grammar, things behave properly.
westocl
@westocl
I also had a second question. Not sure if any one can help. I am trying to use dragonfly to save a file in Notepad++ and continue on and do other things. Currently I am using the KeyAction('c-s'). The problem I am having is that it is not subsequent code runs before the file is saved. I noticed that the Clipboard toolkit has something called 'synchronized_changes'. Is there anything like that to monitor if a file get saved?
David Zurow
@daanzu
@westocl WSR determines precedence between ambiguous grammars based on when they were activated, which can be indirectly affected by their load order
@samVanDerStoop Learning and using dragonfly is great education in programming in and of itself. It is an accomplishment. Trial by fire/practice!
westocl
@westocl
@daanzu thanks for the response. Do you think the safest thing for me to do is place all of the rules into a single grammar?
Rebecca Stevenson
@rebeccaFste_twitter
Quick question: what is the name of the Windows key when it is not a modifier? E.g. something like Key ("Windows") not Key ("w-tab")
David Zurow
@daanzu
@westocl Sure, if that works, go for it, although that might not solve everything. WSR definitely has some quirks to be careful of.
@rebeccaFste_twitter Key("win")
2 replies
samVanDerStoop
@samVanDerStoop
In trying to use the shortcuts for returning to a previous cursor position specific to certain text editors, (ctrl+alt+z for Word, alt+left for Vscode), Ive noticed they don't seem to account for certain actions like pressing the home or end key, both of which move the cursor. Has anyone here tried to use these with success?
westocl
@westocl
@daanzu . Ok it seems to work with WSR (for now). On that same note. I see dragonfly default changed to Kaldi. Besides a quick google search I dont know much about Kaldi. Can you give me a quick explanation about why Kaldi seems to be the way to go by default?
David Zurow
@daanzu
@westocl WSR's speech engine hasn't been improved since maybe 2005. It hasn't really even had any development at all since maybe 2008. Kaldi has been at the forefront of speech recognition research and practice for the past 5+ years, is under active maintenance, and is free and open source. Also, if you want to put in the effort, you can train a customized speech model for yourself for wildly better accuracy.
FWIW, I used WSR for years before/while writing the kaldi backend