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

Grammar lists do not work correctly with Dragon 15 in some cases #82

Open
drmfinlay opened this issue Nov 21, 2021 · 14 comments
Open

Grammar lists do not work correctly with Dragon 15 in some cases #82

drmfinlay opened this issue Nov 21, 2021 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@drmfinlay
Copy link
Member

Natlink's named/dynamic grammar list functionality does not work correctly with Dragon 15 if used in a stand-alone Python process. However, it works just fine in a command module loaded by natspeak.exe. The related methods are GramObj.appendList() and GramObj.emptyList().

The problem can be replicated by running my sample_list.py Natlink command module. The module will load without issue, but Dragon will fail to match a spoken or mimicked command to the grammar. If one says, for example, "this big red object is good," Dragon will normally output the spoken words instead. It would seem that Dragon is either not receiving or not setting the list words and therefore cannot recognize the command. If the module is loaded into natlink normally via the user directory, it will work properly.

This behaviour occurs in the older Python 2.7 and the newer Python 3.8 versions of Natlink.

I note that this can only be related to the C++ code since Dragonfly, which uses the GramObj class directly, has the same problem.

This issue, if it is indeed fixable and not another Dragon "quirk" we must simply endure, should be considered low priority since Natlink is not normally used in this fashion.

@DanKaplanSES
Copy link

This would add convenience for me, because it would allow me to have a dragonfly grammar that consistently capitalizes words.

@drmfinlay
Copy link
Member Author

drmfinlay commented Mar 2, 2022 via email

@LexiconCode
Copy link
Member

LexiconCode commented Aug 24, 2022

DNS 13 is the expected outcome for in process?

Heard macro "sample list"
Heard macro "sample list"

Updated the imports from @Danesprite example.

import natlink
from natlinkcore.natlinkutils import GrammarBase
# spec "this big red object is good"
class ThisGrammar(GrammarBase):

    gramSpec = """
        <start> exported = this <ruleOne> is {list};
        <ruleOne> = big <ruleTwo> object;
        <ruleTwo> = red | blue;
    """
    
    def initialize(self):
        self.load(self.gramSpec)
        self.activateAll()

        # Add a dynamic list containing the words "good" and "bad".
        self.setList("list", ["good", "bad"])

    def gotResults_start(self,words,fullResults):
        natlink.playString('Heard macro "sample list"{enter}')

if __name__ == '__main__':
    natlink.natConnect()

thisGrammar = ThisGrammar()
thisGrammar.initialize()

def unload():
    global thisGrammar
    if thisGrammar: thisGrammar.unload()
    thisGrammar = None

if __name__ == '__main__':
    try:
        natlink.waitForSpeech()
    finally:
        natlink.natDisconnect()

@LexiconCode
Copy link
Member

LexiconCode commented Aug 24, 2022

Out of process - Make sure DNS process is not running

Kill dns process

taskkill /IM natspeak.exe /f /s localhost
taskkill /IM dgnuiasvr_x64.exe /f /s localhost
taskkill /IM dnsspserver.exe /f /s localhost
taskkill /IM dragonbar.exe /f /s localhost
sleep 1

reboot.zip

When loading the script the following traceback occurs and DNS processes must be killed.

GramClassBase.load, Error at loading the grammar: A SRERR_NOUSERSELECTED error occurred calling ISRCentral::GrammarLoad from GrammarObject.cpp 283.
Traceback (most recent call last):
  File "c:\Users\MainLaptop\Documents\Caster\_test.py", line 26, in <module>
    thisGrammar.initialize()
  File "c:\Users\MainLaptop\Documents\Caster\_test.py", line 17, in initialize
    self.setList("list", ["good", "bad"])
  File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python310-32\lib\site-packages\natlinkcore\natlinkutils.py", line 888, in setList
    self.emptyList(listName)
  File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python310-32\lib\site-packages\natlinkcore\natlinkutils.py", line 874, in emptyList
    raise ValueError( 'list "%s" was not defined in the grammar, validLists: %s' % (listName, self.validLists))
ValueError: list "list" was not defined in the grammar, validLists: []

@drmfinlay
Copy link
Member Author

drmfinlay commented Sep 12, 2022

Sorry for the late reply, @LexiconCode.

I'm not sure why it is printed out twice, but yes, that is a reasonable outcome for natspeak.exe.

The other error you're seeing is likely unrelated. SRERR_NOUSERSELECTED indicates the user profile has not yet been loaded. It looks like this error is handled improperly in natlinkutls.py. Consequently, when setList() is called, another error occurs.

I do not see the point of using Natlink in this fashion. If the library is to be used "out of process," DNS should have started up properly and the Natlink messages window should be present. There should be no need to close DNS as long as each grammar is unloaded before the remote process -- python.exe -- disconnects. And that might be done automatically anyway, I don't recall.

Incidentally, I have run Dragonfly's test suite "out of process" for years now without having to close/restart DNS.

@drmfinlay
Copy link
Member Author

@quintijn

There are a number of Natlink quirks like this one that are likely unfixable. It might be better to simply list them all together in one place and reserve the GitHub issue tracker for things that can be fixed. What I have in mind is something like the sections sometimes found at the end of UNIX manual pages, e.g. csh(1), Bugs.

Do you know if there is a sort of Natlink "bugs," "caveats," or "limitations" list somewhere already?

@quintijn
Copy link
Contributor

Hi Dane, I had read this one before, but it was not in my attention. I will look at this soon (still on vacation for the coming week).

Please mention other things as an issue too, More structure we can think about later, first see what we can tackle...

@drmfinlay
Copy link
Member Author

drmfinlay commented Sep 13, 2022 via email

@dougransom
Copy link
Member

hi Dane, I added you as a potential assignee as well. If anyone wants to take a stab at this they would be welcome.

@quintijn
Copy link
Contributor

I will take the first step on this!

@drmfinlay
Copy link
Member Author

drmfinlay commented Sep 16, 2022 via email

@quintijn
Copy link
Contributor

Dane, when trying your grammar, it just works. Recently there was a fix with recognitionMimic and lists. Could you please try again your example grammar, after installing the latest installer, that LexiconCode will release soon?

@drmfinlay
Copy link
Member Author

All right. I think this issue can be closed then.

@drmfinlay
Copy link
Member Author

This is still an issue with Dragon 15. It only occurs out of process. I'm reopening this issue because of #198.

Strangely, I can add and speak list items if they're single characters — letters and numbers. It seems that any item longer than one character will append to a list successfully, but won't match via speech or mimic.

@drmfinlay drmfinlay reopened this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants