Topics

stuck at issue while developing NVDA plugin


CYBER मावळा
 

Hello sir,
Sharang here, as I said I am developing a voice command based math equation reader plugin for NVDA screen reader.The idea is, user will give a voice command such as , 'go the next step', 'go to the previous step' , 'how many terms in the equation?', 'speak slowly' etc..and my plugin will process those voice commands and carry out a task as per the voice command
So i will be explaining in detail, what i have done uptill now

first I will present my folder structure..
NVDA user configuration directory 
       scratchpad
                globalPlugins
                      plugin.py
                      modules
                            wit.py
                            recorder.py
                            __init__.py

As u can see through structure , I have created the  'modules' package(by incorporating  __init__.py), and there I saved 2  python scripts.
recorder.py => imports pyaudio and captures voice command in .wav file
wit.py => calls recorder.py for voice command, does api call, processes  json response and extracts intent of the voice command 
this works fine, when i run wit.py 

Now i am presenting source code for the  plugin.py , which is my global plugin 

import globalPluginHandler
from scriptHandler import script
import sys
import os
import speech
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), 'modules'))   # adding a  path to modules 
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip')  # adding standard python path so that it can access the 3rd part modules,
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs') # all these paths are the output of print(sys.path), I ran in idle interpreter
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages')
from modules import wit

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
    @script(gesture="kb:NVDA+b")
    def script_announceNVDAVersion(self, gesture):
        from modules import wit
        object = wit.RecognizeSpeech()
        print(object)
 
now i m presenting the log, which is filled with errors.

ERROR - globalPluginHandler.listPlugins (15:54:42.491) - MainThread (20024):
Error importing global plugin modules
Traceback (most recent call last):
  File "globalPluginHandler.pyc", line 23, in listPlugins
AttributeError: module 'globalPlugins.modules' has no attribute 'GlobalPlugin'


ERROR - scriptHandler.executeScript (15:56:11.883) - MainThread (20024):
error executing script: <bound method GlobalPlugin.script_announceNVDAVersion of <globalPlugins.plugin.GlobalPlugin object at 0x0409E4F0>> with gesture 'NVDA+b'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 208, in executeScript
  File "C:\Users\sharangk\AppData\Roaming\nvda\scratchpad\globalPlugins\plugin.py", line 18, in script_announceNVDAVersion
    from modules import wit
ModuleNotFoundError: No module named 'modules'

here is sys.path
['C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Program Files (x86)\\NVDA\\library.zip', 'C:\\Program Files (x86)\\NVDA', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

i can clearly see the path to my module but it is not imported 

so to avoid the complexity of importing from module, I simply try to import pyaudio but following error comes
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\sharangk\AppData\Local\Programs\Python\Python37\lib\site-packages\pyaudio.py", line 116, in <module>
    import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'

Please help me to resolve the issue . I am attaching my source files with this email
I am using reload plugin after starting of nvda


Thanks and regards 
sharang


























                     

                           


        




  


CYBER मावळा
 



---------- Forwarded message ---------
From: CYBER मावळा <tocshark2@...>
Date: Tue, Oct 20, 2020 at 4:22 PM
Subject: stuck at issue while developing NVDA plugin
To: <nvda-devel@groups.io>, <s.tolstoyevski@...>, <blueyonder.co.uk@groups.io>


Hello sir,
Sharang here, as I said I am developing a voice command based math equation reader plugin for NVDA screen reader.The idea is, user will give a voice command such as , 'go the next step', 'go to the previous step' , 'how many terms in the equation?', 'speak slowly' etc..and my plugin will process those voice commands and carry out a task as per the voice command
So i will be explaining in detail, what i have done uptill now

first I will present my folder structure..
NVDA user configuration directory 
       scratchpad
                globalPlugins
                      plugin.py
                      modules
                            wit.py
                            recorder.py
                            __init__.py

As u can see through structure , I have created the  'modules' package(by incorporating  __init__.py), and there I saved 2  python scripts.
recorder.py => imports pyaudio and captures voice command in .wav file
wit.py => calls recorder.py for voice command, does api call, processes  json response and extracts intent of the voice command 
this works fine, when i run wit.py 

Now i am presenting source code for the  plugin.py , which is my global plugin 

import globalPluginHandler
from scriptHandler import script
import sys
import os
import speech
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), 'modules'))   # adding a  path to modules 
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip')  # adding standard python path so that it can access the 3rd part modules,
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs') # all these paths are the output of print(sys.path), I ran in idle interpreter
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages')
from modules import wit

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
    @script(gesture="kb:NVDA+b")
    def script_announceNVDAVersion(self, gesture):
        from modules import wit
        object = wit.RecognizeSpeech()
        print(object)
 
now i m presenting the log, which is filled with errors.

ERROR - globalPluginHandler.listPlugins (15:54:42.491) - MainThread (20024):
Error importing global plugin modules
Traceback (most recent call last):
  File "globalPluginHandler.pyc", line 23, in listPlugins
AttributeError: module 'globalPlugins.modules' has no attribute 'GlobalPlugin'


ERROR - scriptHandler.executeScript (15:56:11.883) - MainThread (20024):
error executing script: <bound method GlobalPlugin.script_announceNVDAVersion of <globalPlugins.plugin.GlobalPlugin object at 0x0409E4F0>> with gesture 'NVDA+b'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 208, in executeScript
  File "C:\Users\sharangk\AppData\Roaming\nvda\scratchpad\globalPlugins\plugin.py", line 18, in script_announceNVDAVersion
    from modules import wit
ModuleNotFoundError: No module named 'modules'

here is sys.path
['C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules', 'C:\\Program Files (x86)\\NVDA\\library.zip', 'C:\\Program Files (x86)\\NVDA', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

i can clearly see the path to my module but it is not imported 

so to avoid the complexity of importing from module, I simply try to import pyaudio but following error comes
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\sharangk\AppData\Local\Programs\Python\Python37\lib\site-packages\pyaudio.py", line 116, in <module>
    import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'

Please help me to resolve the issue . I am attaching my source files with this email
I am using reload plugin after starting of nvda
please allow me to contact you using google hangout so we can discusss thse issue and clarify my doubts and curosity about NVDA.


Thanks and regards 
sharang


























                     

                           


        




  


James Scholes
 

You should package your add-on (or use a folder within the addons
directory with a manifest) as soon as it starts to grow beyond a single
file. The scratchpad is scanned recursively for global plugins, app
modules, etc, But pyaudio and your other dependencies are not valid
NVDA add-ons so they fail to load.

In addition, attempting to load DLLs from an external Python
installation, and using absolute paths which are only valid on your
system, is likely to cause more errors and make your add-on quite
fragile. When you've created a proper add-on folder with a manifest,
place the required third party or stlib modules in there, including all
compiled dependencies that they need.

Finally, consider subscribing to the NVDA add-ons group if you haven't
already; there is much more add-on-related traffic there.

Regards,

James Scholes

On 20/10/2020 at 5:52 am, CYBER मावळा wrote:
Hello sir,
Sharang here, as I said I am developing a voice command based math
equation reader plugin for NVDA screen reader.The idea is, user will
give a voice command such as , 'go the next step', 'go to the previous
step' , 'how many terms in the equation?', 'speak slowly' etc..and my
plugin will process those voice commands and carry out a task as per the
voice command
So i will be explaining in detail, what i have done uptill now

first I will present my folder structure..
NVDA user configuration directory 
       scratchpad
                globalPlugins
                      plugin.py
                      modules
                            wit.py
                            recorder.py
                            __init__.py

As u can see through structure , I have created the  'modules'
package(by incorporating  __init__.py), and there I saved 2  python scripts.
recorder.py => imports pyaudio and captures voice command in .wav file
wit.py => calls recorder.py for voice command, does api call, processes 
json response and extracts intent of the voice command 
this works fine, when i run wit.py 

Now i am presenting source code for the  plugin.py , which is my global
plugin 

import globalPluginHandler
from scriptHandler import script
import sys
import os
import speech
sys.path.insert(0,
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'modules'))   #
adding a  path to modules 
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip') 
# adding standard python path so that it can access the 3rd part modules,
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs')
# all these paths are the output of print(sys.path), I ran in idle
interpreter
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37')
sys.path.append('C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages')
from modules import wit

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
    @script(gesture="kb:NVDA+b")
    def script_announceNVDAVersion(self, gesture):
        from modules import wit
        object = wit.RecognizeSpeech()
        print(object)
 
now i m presenting the log, which is filled with errors.

ERROR - globalPluginHandler.listPlugins (15:54:42.491) - MainThread (20024):
Error importing global plugin modules
Traceback (most recent call last):
  File "globalPluginHandler.pyc", line 23, in listPlugins
AttributeError: module 'globalPlugins.modules' has no attribute
'GlobalPlugin'


ERROR - scriptHandler.executeScript (15:56:11.883) - MainThread (20024):
error executing script: <bound method
GlobalPlugin.script_announceNVDAVersion of
<globalPlugins.plugin.GlobalPlugin object at 0x0409E4F0>> with gesture
'NVDA+b'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 208, in executeScript
  File
"C:\Users\sharangk\AppData\Roaming\nvda\scratchpad\globalPlugins\plugin.py",
line 18, in script_announceNVDAVersion
    from modules import wit
ModuleNotFoundError: No module named 'modules'

here is sys.path
*['C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\module*s',
'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules',
'C:\\Users\\sharangk\\AppData\\Roaming\\nvda\\scratchpad\\globalPlugins\\modules',
'C:\\Program Files (x86)\\NVDA\\library.zip', 'C:\\Program Files
(x86)\\NVDA',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37',
'C:\\Users\\sharangk\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']

*i can clearly see the path to my module but it is not imported *

so to avoid the complexity of importing from module, I simply try to
import pyaudio but following error comes
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File
"C:\Users\sharangk\AppData\Local\Programs\Python\Python37\lib\site-packages\pyaudio.py",
line 116, in <module>
    import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'

Please help me to resolve the issue . I am attaching my source files
with this email
I am using reload plugin after starting of nvda


Thanks and regards 
sharang