dictation-toolbox / natlink

Natlink provides the interface between Dragon and python
https://dictation-toolbox.github.io/natlink/
Other
25 stars 17 forks source link

Multiple Points Needing Clarity & Direction [Help Wanted] #157

Open rxcube opened 1 year ago

rxcube commented 1 year ago

Context: I am on windows 10 in an enterprise controlled environment on a non-admin account where only approved software here can run and I cannot actively change my account from "non-admin" to "admin" because to do that requires admin which I don't have. I can get another admin account to install stuff as needed for installation purposes, but I cannot run stuff from my account as admin ever and this is not flexible. That's not how things work when you work in an enterprise windows version managed by others who are admin. I have a bad hand injury and it's critical I can get Natlink and Dragonfly to work properly and configured properly to be able to do my job hands free via voice only and my job is complicated and difficult now that I'm injured. I have Dragon Naturally Speaking pro purchased version 15, python 3.10-32, natlink 5.4.4, natlinkcore 5.3.5 and dragonfly2 0.35.0 showing as installed in the pip list using the 'py -m pip list' command in the cmd windows console. My user account will always be a non-admin and this is out of my control. My use of Natlink is only for Dragonfly at this time which I am still trying to configure and learn also.

Questions For Clarity:

  1. Documentation says "When you want another directory for your file natlink.ini to be in, you can set this in the environment variable 'NATLINK_USERDIR'. For example, when you want your config files (especially natlink.ini) in a subdirectory of your Documents folder, set this environment variable to '~/Documents/.natlink'." But documentation doesn't say where or how to set the variable. Where can a user set variables? In what .exe console or program? With what command?

  2. Using Natlink's GUI to configure it to work with Dragonfly adds an entry to the natlink.ini file as: dragonflyuserdirectory = ~\Documents\Natlink but in the default config version of the .ini file, it has Dragonfly = ~\Documents\Natlink - so which is correct? dragonflyuserdirectory = or Dragonfly = ? It's confusing that there is not consistency to understand things. A similar lack of clarity exists when I see 'userdirectory =' and 'UserDirectory =' both being used in different places based on what a user does with the config tools or in default installed files. Are these both the same or is this case sensitive? How is this 'userdirectory' or 'UserDirectory' different from the 'natlinkuserdirectory =' entry I've seen included at the end of .ini files?

  3. When would a person need a folder for 'Dragonfly' folder or a 'user directory' folder or a 'natlinkuserdirectory' folder specified? Are these all the same thing just written three different ways? It's confusing to not understand the different unique purposes of these various folder options for the .ini file with a real life practical example of using all three to see in practice the purpose.

  4. I made the .ini file in both the user\ .natlink\ folder and the default config folder identical so there's no possibility the .ini is the issue - and when Dragon Naturally Speaking loads, Natlink info window that loads with Dragon Naturally Speaking still says "Warning, no directories specified for Natlink grammars, falling back to default configuration "C:\Program Files (x86)\Python310-32\lib\site-packages\natlinkcore\DefaultConfig"" What am I doing wrong? Seems overly complicated if all the .ini files show I've picked directories and it still doesn't get recognized when Dragon loads.

  5. I noticed the Default Config installed .ini file for natlink configuration has a few helpful comments that some auto-generated .ini file in the user\ .natlink\ folder doesn't contain - not sure if that's due to the GUI or the command line interface program or the copying of a .ini from default config by the code, but basically two .ini files exist and before I edited them to make them identical the one in the user directory didn't have all the helpful comments the other default config one had. When you do testing you should be making sure the command line interface, GUI, and any auto-copied version contain all the same helpful info as comments because this is not happening somewhere along the way and the program or programs or something it did produce two different .ini files initially before I forced them both to be the same. One had the helpful comments, one did not.

  6. It is unclear if the '~\Documents\UserDirectory' format is supported in the version I'm running? In one of your comments on this website you stated that the full direct userpath such as C:\User\X\ would have to be used instead of ~\ due to some issue - is that still correct and do the paths have to be fully written in the .ini files as C:\User\X\somefolder or can a person use the format of ~\somefolder ???

I can only respond 4 work days a week that I work and I would not bother you to respond on any weekend at all please, but I appreciate your response on those 4 days I work. Thank you for your assistance, it is greatly appreciated. Thank you for developing this program and your efforts. Below is my current configuration in my natlink.ini file for your examination and comments as well. Thanks,

rxcube

natlink.ini contents:

[directories]
# specify the directory / directories that are loaded when Natlink starts:
# typically a single line below needs uncommenting, but more is also possible
# Caster = C:\User\X\Dropbox\Caster
# Dragonfly = C:\User\X\Dropbox\Dragonfly
# Vocola = C:\User\X\Dropbox\Vocola
# Unimacro = C:\User\X\Dropbox\Unimacro
# UserDirectory = C:\User\X\Dropbox\UserDirectory    ## can be the same as Dragonfly or Caster directory
# directions say somewhere to delcare this NATLINK_USERDIR variable - is this the right place to do so in this natlink.ini file?
NATLINK_USERDIR = C:\Users\rxcube\Documents\Natlink
Dragonfly = C:\Users\rxcube\Documents\Natlink
# possible below line was old way and above line is new way Dragon recognizes?  Unclear to me.
dragonflyuserdirectory = C:\Users\rxcube\Documents\Natlink
# Found below line method at https://github.com/dictation-toolbox/natlink/blob/master/documentation/configure.rst
NatlinkUser = C:\Users\rxcube\Documents\Natlink
# how is NatlinkUser different from NATLINK_USERDIR and UserDirectory - so confusing.
#userdirectory = C:\Users\rxcube\Documents\Natlink - this line was default in user folder .natlink folder .ini I edited
# commented out above line because appears it isn't recognized correctly by Dragon but below line is?  or am I confused?  Just so unsure of differences if case sensitive or which is more current and correct.
UserDirectory = C:\Users\rxcube\Documents\Natlink

[settings]
# some comments added by me taking additional info from documentation on website that was not in here and adding for me to understand these things better.  Recommend default installation should contain more comprehensive comments, instructions, and info for beginners using this.
#
# log_level: the log level to set the Natlink logger to. 
# Possible values are: CRITICAL, FATAL, ERROR, WARNING, INFO, DEBUG, NOTSET 
# (default: NOTSET), but start normally with INFO
log_level = INFO
#
# Determine when to check for new or changed scripts and then load or reload them.
#
# Load scripts after Dragon has loaded Natlink (default: True)
load_on_startup = True
#
# At the beginning of each utterance (default: False)
load_on_begin_utterance = False
#
# When the microphone state changes to "on" (default: True)
load_on_mic_on = True
#
# load or reload when the user profile changes.
load_on_user_changed = True

[manual configuration]
instruction1 = set next line in the directories section when you
instruction2 = want to define a Natlink user directory, independent of
instruction3 = any package, like Dragonfly, Unimacro or Vocola.
instruction4 = Note: you can drop a python grammar file in any of the directories,
instruction5 = the distinction is made for package updates, and for convenience
# what is purpose of below 'natlinkuserdirectory =' statement compared to above userdirectory = or UserDirectory = or NATLINK_USERDIR =?  Not clear differences of all these things.  Very similar names to them with no clear distinction between their uses/when/why.
natlinkuserdirectory = C:\Users\rxcube\Documents\Natlink
# unsure - why would someone want to manual configure something here under [manual configuration] instead of above under [directories] section?  Confusing and unclear the purpose of this section as compared to the other section of this .ini file?
quintijn commented 1 year ago

Hi rxcube,

Sorry things are confusing and not working out sofar. We are still in a beta phase, already for too long. With the next version a few path names will change again...

About all those admin or non admin things, I am not very confident to answer, but you seem to have Natlink running, so that is probably no issue any more.

Let me go over point by point:

  1. NATLINK_USERDIR environment variable is also going to be changed into another name. But you don't need it probably. We don't explain how to set a environment variable, as we think this is common windows knowledge. But you do not need to set this environment variable.

  2. This seems strange. But let me first explain the capitalisation issue: we are used to UserDirectory, DragonflyDirectory etc. but the program which sets the "key" names of the natlink.ini file, makes them all lower case. They refer all to the same.

  3. We then want to specify a directory where you can drop you dragonfly grammar files (.py files). It is convenient to do so in the DragonflyDirectory , but Natlink works equally well, when you define a UserDirectory, and drop them there.

  4. You should never see the DefaultConfig natlink.ini file. When using the config program, your ini file should be set correctly.

  5. So forget about the example in DefaultConfig.

  6. You can type out (or copy paste) the paths you want, the ~ notation is just for convenience. If you are not confident this notation works on your system, use typed out paths!

Hope this helps. Be prepared for changes with new upcoming (pre) releases. But when this works, you probably can go forward until a stable release is there. Good luck, Quintijn

LexiconCode commented 1 year ago

I understand your pain about corporate environments. Administrator privileges as required to provide write access to the two following files Nsapps.ini or nssystem.ini.

Nsapps.ini the installer appends the following which allows Natlink C++ interface to load on startup.

[.Natlink]
App Support GUID={dd990001-bb89-11d2-b031-0060088dc929}

You can read into a lot more detail in the following NatlinkSource/readme.md

rxcube commented 1 year ago

Hi,

Thank your reply, and I understand you’re probably a very busy person, but the shortened answers provided did not actually answer the questions asked, and I still need understanding and help.

For Question 1: Thank you for giving a perspective that you don’t view this NATLINK_USERDIR variable as necessary, or that you might remove it in future versions, or that you view environment variables as common knowledge, but in the version I have 5.4.4 it's still relevant and helpful and important to help others understand the answer to the question. My goal is to understand all features, all configuration files, how to manually adjust files/settings/configurations, all variables and how to use them to eliminate warning messages to ensure the program is working as intended "for certain" not with any doubts wondering why something doesn't work in the future (if something didn't work later on). So the question about the NATLINK_USERDIR variable and environment variables was important to answer.

I have been using Windows since the mid 90’s and I’m considered a more advanced computer user than most people I know but even I did not know how to set a windows variable before asking so providing a link or instructions could have saved me time and I’m sure other users in the future would appreciate this information. Can you verify these instructions to set the NATLINK_USERDIR variable are correct:

INSTRUCTIONS TO ADD NATLINK_USERDIR WINDOWS ENVIRONMENT VARIABLE a) In display settings: Change display % to either 100% or 125% because one of the windows dialogue boxes you will encounter won’t display the bottom “OK” button correctly if you go into it and then change the % for your display later. (this is an important note for people who have bad vision whose display is not 100% but larger) b) Search for advanced system properties using the start search button and run the ‘View advanced system settings’ app (probably admin needed to do this but I’m not certain) c) Click ‘Environment Variables’ button to open environmental variables windows dialogue box. d) Under the top section for ‘User variables for rxcube’ (it will show your username instead of rxcube), click the “New” button (which should be in the middle of the dialog box) (Note – is this correct? I assume so but this is why detailed instructions are important to provide since there are both user variables and system variables and I’m guessing here.) e) Enter this info and click OK: i) Variable name: NATLINK_USERDIR ii) Example Variable value: C:\Users\rxcube\Documents\ .natlink (but don't put a space before .natlink - I only did that in this example because github would not display the directory right if I didn't) (replace rxcube with your windows username instead) Important Note: Directory must end with .natlink exactly with the period . in the folder name for it to work right. Other info mentioned at https://natlink.readthedocs.io/en/latest/configure.html f) Verify entry for Natlink variable and click OK on the bottom (MUST click OK to apply or possibly press enter). g) Go back into environment variables by clicking button again to go in and check the entry applied and saved. Then exit that and the system properties windows by clicking OK. You can also check it’s added by opening cmd command prompt (maybe as admin needed not sure) and running the set command – just type set and press enter to view environment variables.

It appears I was successful in changing the location of where the natlink.ini file goes using this method to add the NATLINK_USERDIR variable, but it may require being made temporarily admin (I was already admin temporarily to do the install, so I can't remember for sure if admin was required for this part for sure - I cannot get permission to be an admin permanently in this enterprise environment).

Question: Are these above instructions correct? Is that correct to make this a user variable instead of a system variable? There are both "System variables" and "User variables" and that’s another reason why clear instructions are helpful to people who have never tinkered with environment variables before to make it clear all the steps to follow so they don’t mess anything up and can enjoy the full benefit of the Natlink program options. Please verify. Thank you.

I am pretty sure that using this variable helped me to eliminate one of the warning messages I was getting, so that's another reason helping people to figure this out is good. I go into more detail on that later in this comment.

For question 2 and 3: a. Your response did not really answer this question clearly. You indicated variables are not case sensitive, and I understand a purpose of some directories are to put grammar files – but my question is more than just about case sensitivity. Maybe the GUI was adding some directories differently than the CLI.

We have these 4 variables that I’ve seen appear:

dragonflyuserdirectory = 
Dragonfly = 
userdirectory =
natlinkuserdirectory =

If there is only 1 single purpose – "to identify a folder where grammar files exist" – then why would there be a need for these 4 separate variable names? The variable ‘dragonflyuserdirectory’ has the phrase ‘userdirectory’ at the end – does that make that variable function different than the ‘Dragonfly’ variable that doesn’t have the phrase ‘userdirectory’ at the end? How is ‘natlinkuserdirectory’ different from ‘userdirectory’ in its purpose?

If they all have one purpose then there should only be one variable so the question is important because I’m trying to ensure the program is running 100% correctly and well with no error messages and become educated on when a user would want to use these 4 variables so I understand the full capabilities of the program and am educated enough to successfully be able to manually edit the .ini file in a meaningful way and understand all my options available.

For Question 4: a. Recommendation: You said when using the config program, my ini file should be set correctly and that I should never see the DefaultConfig natlink.ini file but I think the CLI and GUI both might be setting things differently and if the DefaultConfig natlink.ini file should not be seen or used then I would suggest deleting it from the installation and not having extra information that is not current or useful for users because that adds to confusion on understanding the way to manually configure the .ini file.

b. The second part to my question 4 was unanswered and I wanted the program to run with no warnings to ensure it’s configured correctly and running smoothly. I used the CLI to configure Natlink but was still getting a warning message when Dragon loads of:

Warning, no directories specified for Natlink grammars,
    falling back to default configuration "C:\Program Files (x86)\Python310-32\lib\site-packages\natlinkcore\DefaultConfig"

I had thought that was set using CLI.exe dragonfly and user directory commands but this warning still showed. I wanted it to run with no warnings showing also to ensure it's 100% configured and working right. The custom directory for Natlink grammars was not being recognized properly. However, I think this was resolved by me doing the following:

1) uninstall all natlink/python programs using windows uninstall feature for apps and then also manually deleting all program file and appdata folders for natlink and python that were used by the program before to ensure no old configurations were messing with the program working right 2) clean install (requires being made admin temporarily) of python and natlink (see below steps 3 and 4 for detailed install instructions I followed for python and natlink) 3) Install python-3.10.9.exe to: C:\Program Files (x86)\Python310-32 (this is also where Natlink would install to). Note: The 3.10.8 installer didn't work for me for some reason but 3.10.9 does. a. place .exe on desktop b. Hold shift and Right click .exe click Copy path c. Run CMD command prompt as admin d. Right click to paste path e. press enter to run .exe f. Followed these install options/steps for python:

  - do not add to path (unchecked 'add python.exe to path')
  - run with admin (checked 'use admin privileges when installing py.exe')
  - clicked custom install and used these options:
  - critical: checked documentation
  - critical: checked pip
  - critical: checked tcl/tk and IDLE
  - unsure if critical: checked Python test suite
  - critical: checked py launcher
  - critical: checked for all users (requires admin privileges) (this last one is definitely super critical for install/configure to work right)

g. click next h. critical: checked 'Install python 3.10 for all users' (also definitely super critical for install/configure to work right) (the previous setting was the py launcher for all users I think whereas this is the python itself) i. checked Associate files with python (requires the 'py' launcher) j. checked create shortcuts for installed applications k. Unsure about 'add python to environment variables' so left unchecked l. checked precompile standard library (makes things run faster I read somewhere? helpful it seems) m. not sure but chose to leave unchecked for download debugging symbols n. installed to: C:\Program Files (x86)\Python310-32 o. Run cmd prompt as admin. p. Enter py -m pip install --upgrade pip Note: In natlink install this may be mentioned to you to update pip so you might as well make sure updated first before natlink is installed.

  1. Install and configure Natlink by... a. place the 5.4.4 installer .exe on desktop b. Hold shift and Right click .exe click Copy path c. Run CMD command prompt as admin d. Right click to paste path e. press enter to run .exe f. Don't use GUI (graphical user interface program .exe) that pops up at end of Natlink install - EXIT THE GUI - it does not seem to work right and makes the .ini file configured differently than the CLI program which creates confusion for new Natlink users. (the GUI [natlinkconfig_gui.exe] and CLI .exe files installed to C:\Program Files (x86)\Python310-32\Scripts if needed) g. Exit GUI h. Followed above instructions (earlier in this comment under Question 1) on how to set the Windows Environment variable NATLINK_USERDIR in 'View advanced system settings' windows app - but I asked above that the developer/programmer verify if it's system or user variable and if those instructions are correct i. Continue Natlink configuration using instructions in 5. below.
  2. Use CLI command line interface a. natlinkconfig_cli.exe located in C:\Program Files (x86)\Python310-32\Scripts b. run as admin c. type commands in command line: u for usage d (lowercase d) for dragonfly directory to be enabled Choose C:\Users\rxcube\Documents\ .natlink (but don't put a space before .natlink - I only did that in this example because github would not display the directory right if I didn't) (replace rxcube with your windows username instead) Note: This also installs Dragonfly (dragonfly2) in python Note: This also sets the 'dragonflyuserdirectory' variable in the .ini file. Note: the capital D (capital d) cleared this entry so don't use capital D unless you are trying to erase your d lowercase d dragonfly entry. To upgrade dragonfly (dragonfly2), also first clear ("D"), then choose this option ("d") again. Note: If you used the 'd' command to set the 'dragonflyuserdirectory' variable, you probably wouldn't use the 'n' command for user directory to be enabled because although it appears to set a different variable in the .ini named 'userdirectory' - setting both 'userdirectory' and 'dragonflyuserdirectory' causes this error to occur:

Attempting to load duplicate module: C:\Users\rxcube\Documents\.natlink\_test123.py)

Note: The above example would show whatever the folder is that you used for d and n commands if they are both the same - this is just an example but your path will be different depending on what your folder is you pick and your username which wouldn't be rxcube. Note: This would be the error showing up if the \Documents\ .natlink folder was your folder for dragonfly set by the d command and user directory n command and you had a test script called _test123.py in it to function as a 'grammar' file - so don't use both d and n on same directory or maybe not n needed at all, unsure. N (capital n) clears this entry from command n (lowercase n) in case you accidentally entered both d and n directories - I don't think two separate ones are needed and seems to create an error. i to provide detailed printout of natlink info j to provide python path info I (capital i) to get current .ini and copy it if need backup q to quit

Side Note: Grammar files must start with underscore _ and end with .py which I didn't know and read somewhere.

  1. New Issue: I get this error message: DPI awareness could not be set; it has been set already.

How do we get rid of this DPI error message?

Thank you for your help for the points where questions still remained.

rxcube