dictation-toolbox / natlink

Natlink provides the interface between Dragon and python
Other
25 stars 17 forks source link

Warning: "no directories specified for Natlink grammars" when no grammar file starts with "_" #181

Closed 77capr closed 6 months ago

77capr commented 6 months ago

I had all my grammar files start with letters instead of underscores. NatLink then put out the above warning on startup and ignored all my grammar files. As soon as I have one grammar file start with an underscore, NatLink will successfully read all of my grammar files in that configured directory.

Is it not a valid configuration to have all grammar files start with a letter? If it's not, could the warning message be improved?

quintijn commented 6 months ago

Ah, the procedure when no valid grammar file is found is a lenghty list of uninteresting things in the Messages from Natlink window.

The answer to your question is: "global" grammars, which are "on" all the time, must start its filename with an "_". otherwise natlink looks for a file that matches the current application (notepad.py or notepad_example.py). See for example an introduction in https://qh.antenna.nl/unimacro/aboutunimacro/history/index.html

77capr commented 6 months ago

Thanks for responding! Yes, I understand that grammar files starting with an underscore are considered global grammars which are "on" irrespective of the current application.

But why does NatLink report that there are no grammar directories defined when I do define a directory and it contains "local" grammars (just no global ones)?

quintijn commented 6 months ago

Hello, yes, this is expected behaviour. At start of Natlink (when Dragon starts), first a search for global grammars is done. At least one file (valid grammar or not), that starts with an "_" (underscore) should be present. Also an empty file "init.py" will do, I think.

The reason is, that at start of Natlink application dependent grammars are not started yet: these will be started when the application is first in the foreground at a speaker utterance.

So please create an empty file "init.py", and see if this works.

Greetings, Quintijn

77capr commented 5 months ago

Okay, I understand the behavior then. In that case, my only suggestion would be to change the warning message for this specific case from saying that there are no directories specified to saying that at least one file that starts with an "_" (underscore) or an empty file "init.py" needs to be present in the configured directory.

It would have saved me a couple of hours of hunting in the wrong direction when I saw the warning message. I thought that for whatever reason it wasn't even reading my configuration file.