Skip to content

Commit

Permalink
v1.5
Browse files Browse the repository at this point in the history
[v1.5]()

• Solve the error that the addon slows down in Internet browsing, especially on Chromium-based browsers, radically.
• Adding the ability to inform about the state of the object via sound in addition to the type.
• Speed up the addition by finding the audio file for the type or state of the object and skipping it if it is not available.
• Improvement of the object details finder and its adjustment based on the settings of the add-on.
• Adding the ability to activate/disable the pronunciation of the object’s state, and it comes by default specified as activated, and it comes next to the box for specifying the pronunciation of the object in the add-on settings interface.
• add more languages: Arabic, English, Italian, French, spanish, Portuguese, Polish, danish, and Chinese simplified.
  • Loading branch information
ahmedthebest31 committed Oct 21, 2023
1 parent 8f89e5b commit b6ed448
Show file tree
Hide file tree
Showing 98 changed files with 575 additions and 40 deletions.
95 changes: 59 additions & 36 deletions navsounds/globalPlugins/NavigationSounds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,55 @@
import wx


sounds1={}
roleSECTION = "NavigationSounds"
confspec = {
"sayRoles": "boolean(default=false)",
"sayStates": "boolean(default=true)",
"soundType": "string(default=default)",
"rolesSounds": "boolean(default=true)",
"cfgSounds": "boolean(default=true)",
"typing": "boolean(default=true)",
"type": "string(default=1blueSwitch)",
"edit": "boolean(default=false)",
"volume": "integer(default=100)"}

config.conf.spec[roleSECTION] = confspec
rolesSounds= config.conf[roleSECTION]["rolesSounds"]
cfgSounds= config.conf[roleSECTION]["cfgSounds"]
sayRoles= config.conf[roleSECTION]["sayRoles"]
sayStates= config.conf[roleSECTION]["sayStates"]

mainPaths=os.path.join(os.path.abspath(os.path.dirname(__file__)))
def loc():
return os.path.join(os.path.abspath(os.path.dirname(__file__)), "effects","navsounds",config.conf[roleSECTION]["soundType"])
return os.path.join(mainPaths, "effects","navsounds",config.conf[roleSECTION]["soundType"])
def loc1():
return os.path.join(os.path.abspath(os.path.dirname(__file__)),"effects","typingsound",config.conf[roleSECTION]["type"])
return os.path.join(mainPaths,"effects","typingsound",config.conf[roleSECTION]["type"])

#Add all the roles, looking for name.wav.
def sounds():
sounds1 = {}
for role in [x for x in dir(controlTypes) if x.startswith('ROLE_')]:
r = os.path.join(loc(), role[5:].lower()+".wav")
sounds1[getattr(controlTypes, role)] = r
return sounds1
#Add all the roles,states looking for name.wav.
def sounds(O):
global sounds1
if(not O.name in sounds1):
pp = os.path.join(loc(), O.name.replace('_','').lower()+".wav")
sounds1[O.name]=pp
return sounds1.get(O.name)

Objects=[] #list for Objects for testing obj containts
def getSpeechTextForProperties2(reason=NVDAObjects.controlTypes.OutputReason, *args, **kwargs):
role = kwargs.get('role', None)
if 'role' in kwargs and role in sounds() and os.path.exists(sounds()[role]) and sayRoles ==False:
states = kwargs.get('states', None)
global Objects;Objects.append([kwargs,args])
if 'role' in kwargs and os.path.exists(sounds(role)) and sayRoles ==False:
del kwargs['role']
if 'states' in kwargs and sayStates ==False:
STATES=[state for state in states if os.path.exists(sounds(state))]
for STATE in STATES:
kwargs['states'].remove(STATE)
return old(reason, *args, **kwargs)

def play(role):
"""plays sound for role."""
f = sounds()[role]
"""plays sound for Object."""
def play(O):
f = sounds(O)
# nvwave.set_volume(40/100)
if os.path.exists(f) and rolesSounds==True:
if cfgSounds and os.path.exists(f):
nvwave.playWaveFile(f, 1)

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
Expand All @@ -73,30 +85,35 @@ def event_typedCharacter(self, obj, nextHandler, ch):
self.play1(ch)
nextHandler()
def event_gainFocus(self, obj, nextHandler):
if rolesSounds == True:
if not sayStates or not sayRoles:
speech.speech.getPropertiesSpeech = getSpeechTextForProperties2
play(obj.role)
if(cfgSounds):
STATES=[s for s in obj.states if os.path.exists(sounds(s))==True]
if len(STATES)>0:
for state in STATES:
play(state);#break
elif os.path.exists(sounds(obj.role)): play(obj.role);#break
nextHandler()

@script(gesture="kb:NVDA+alt+n")
def script_toggle(self, gesture):
global rolesSounds
sayRoles =config.conf[roleSECTION]["typing"]
global cfgSounds
cfgTyping =config.conf[roleSECTION]["typing"]
isSameScript = getLastScriptRepeatCount()
if isSameScript == 0:
rolesSounds = not rolesSounds
if rolesSounds==False:
cfgSounds = not cfgSounds
if cfgSounds==False:
ui.message(_("Disable navigation sounds"))
else:
ui.message(_("Enable navigation sounds"))
elif isSameScript ==1:
sayRoles = not sayRoles
if sayRoles ==False:
cfgTyping = not cfgTyping
if cfgTyping ==False:
ui.message(_("Disable typing sounds"))
else:
ui.message(_("Enable typing sounds"))
config.conf[roleSECTION]["typing"] = sayRoles
config.conf[roleSECTION]["rolesSounds"] = rolesSounds
config.conf[roleSECTION]["typing"] = cfgTyping
config.conf[roleSECTION]["cfgSounds"] = cfgSounds
script_toggle.__doc__= _("Pressing it once toggles between on and off object sounds, and Pressing twice it toggles between on and off typing sounds.")
def terminate(self):
NVDASettingsDialog.categoryClasses.remove(NavSettingsPanel)
Expand All @@ -107,19 +124,21 @@ def makeSettings(self, settingsSizer):
sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
self.tlable = sHelper.addItem(wx.StaticText(self, label=_("select sound"), name="ts"))
self.sou= sHelper.addItem(wx.Choice(self, name="ts"))
self.sou.Set(os.listdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "effects","navsounds")))
self.sou.Set(os.listdir(os.path.join(mainPaths, "effects","navsounds")))
self.sou.SetStringSelection(config.conf[roleSECTION]["soundType"])
self.nas=sHelper.addItem(wx.CheckBox(self,label=_("say roles")))
self.nas.SetValue(config.conf[roleSECTION]["sayRoles"])
self.nar=sHelper.addItem(wx.CheckBox(self,label=_("say roles")))
self.nar.SetValue(config.conf[roleSECTION]["sayRoles"])
self.nas=sHelper.addItem(wx.CheckBox(self,label=_("say states")))
self.nas.SetValue(config.conf[roleSECTION]["sayStates"])
self.nab=sHelper.addItem(wx.CheckBox(self,label=_("navigation sounds")))
self.nab.SetValue(config.conf[roleSECTION]["rolesSounds"])
self.nab.SetValue(config.conf[roleSECTION]["cfgSounds"])
self.ts=sHelper.addItem(wx.CheckBox(self,label=_("keyboard typing sound")))
self.ts.SetValue(config.conf[roleSECTION]["typing"])
self.edit=sHelper.addItem(wx.CheckBox(self,label=_("enable typing sound in text boxes only")))
self.edit.SetValue(config.conf[roleSECTION]["edit"])
self.tlable1 = sHelper.addItem(wx.StaticText(self, label=_("select typing sound"), name="tt"))
self.sou1= sHelper.addItem(wx.Choice(self, name="tt"))
self.sou1.Set(os.listdir(os.path.join(os.path.abspath(os.path.dirname(__file__)), "effects","typingsound")))
self.sou1.Set(os.listdir(os.path.join(mainPaths, "effects","typingsound")))
self.sou1.SetStringSelection(config.conf[roleSECTION]["type"])
self.tlable2 = sHelper.addItem(wx.StaticText(self, label=_("volume"), name="tt2"))
self.sou2= sHelper.addItem(wx.SpinCtrl(self, name="tt2",min=0,max=100))
Expand All @@ -134,16 +153,20 @@ def postInit(self):
def onopen(self,event):
os.startfile(os.path.join(os.path.abspath(os.path.dirname(__file__)), "effects"))
def onSave(self):
global sayRoles,rolesSounds
global sayRoles,sayStates,cfgSounds ,sounds1
config.conf[roleSECTION]["soundType"]=self.sou.GetStringSelection()
config.conf[roleSECTION]["sayRoles"]=self.nas.GetValue()
config.conf[roleSECTION]["sayRoles"]=self.nar.GetValue()
sayRoles=config.conf[roleSECTION]["sayRoles"]
config.conf[roleSECTION]["rolesSounds"]=self.nab.GetValue()
rolesSounds=config.conf[roleSECTION]["rolesSounds"]
config.conf[roleSECTION]["sayStates"]=self.nas.GetValue()
sayStates=config.conf[roleSECTION]["sayStates"]
config.conf[roleSECTION]["cfgSounds"]=self.nab.GetValue()
cfgSounds=config.conf[roleSECTION]["cfgSounds"]
config.conf[roleSECTION]["typing"]=self.ts.GetValue()
config.conf[roleSECTION]["edit"]=self.edit.GetValue()
config.conf[roleSECTION]["type"]=self.sou1.GetStringSelection()
config.conf[roleSECTION]["volume"]=self.sou2.GetValue()
sounds1={}
def ondonate(self,e):
ui.message("please wait")
web.open("https://www.paypal.me/ahmedthebest31")
web.open("https://www.paypal.me/ahmedthebest31")
ui.message("donation link is opened")
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[LocalizedFileNames]
Windows Startup.wav=@%windir%\system32\mmres.dll,-735
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified navsounds/locale/ar/LC_MESSAGES/nvda.mo
Binary file not shown.
83 changes: 83 additions & 0 deletions navsounds/locale/ar/LC_MESSAGES/nvda.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2023-10-19 16:06+0300\n"
"PO-Revision-Date: 2023-10-21 18:26+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ar\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.3.2\n"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:67
#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:122
#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:133
msgid "navigation sounds"
msgstr "أصوات التنقل"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:106
msgid "Disable navigation sounds"
msgstr "تعطيل أصوات التنقل"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:108
msgid "Enable navigation sounds"
msgstr "تفعيل أصوات التنقل"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:112
msgid "Disable typing sounds"
msgstr "تعطيل أصوات الكتابة"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:114
msgid "Enable typing sounds"
msgstr "تفعيل أصوات الكتابة"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:117
msgid ""
"Pressing it once toggles between on and off object sounds, and Pressing "
"twice it toggles between on and off typing sounds."
msgstr ""
"يءدي الضغت عليه مرة واحدة إلى تفعيل/تعطيل أصوات التنقل ومرتين لتفعيل/"
"تعطيل أصوات الكتابة"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:125
msgid "select sound"
msgstr "أختر الصوت"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:129
msgid "say roles"
msgstr "نطق أنواع الكائنات"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:131
msgid "say states"
msgstr "نطق حالة العنصر"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:135
msgid "keyboard typing sound"
msgstr "أصوات الكتابة على اللوحة"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:137
msgid "enable typing sound in text boxes only"
msgstr "تفعيل أصوات الكتابة في مربعات التحرير فقت"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:139
msgid "select typing sound"
msgstr "أختر أصوات الكتابة"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:143
msgid "volume"
msgstr "ألصوت"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:147
msgid "open sounds folder"
msgstr "فتح مجلد الأصوات"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:149
msgid "donate"
msgstr "تبرع"
Binary file modified navsounds/locale/es/LC_MESSAGES/nvda.mo
Binary file not shown.
84 changes: 84 additions & 0 deletions navsounds/locale/es/LC_MESSAGES/nvda.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2023-10-19 16:06+0300\n"
"PO-Revision-Date: 2023-10-21 18:39+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.3.2\n"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:67
#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:122
#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:133
msgid "navigation sounds"
msgstr "sonidos de navegación"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:106
msgid "Disable navigation sounds"
msgstr ""

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:108
msgid "Enable navigation sounds"
msgstr ""

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:112
msgid "Disable typing sounds"
msgstr ""

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:114
msgid "Enable typing sounds"
msgstr ""

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:117
msgid ""
"Pressing it once toggles between on and off object sounds, and Pressing "
"twice it toggles between on and off typing sounds."
msgstr ""
"Presionarlo una vez alterna entre sonidos de objeto activados y "
"desactivados, y presionarlo dos veces alterna entre sonidos de tecleo "
"activados y desactivados."

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:125
msgid "select sound"
msgstr "seleccionar sonido"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:129
msgid "say roles"
msgstr "decir roles"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:131
msgid "say states"
msgstr "decir estados"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:135
msgid "keyboard typing sound"
msgstr "sonido de tecleo"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:137
msgid "enable typing sound in text boxes only"
msgstr "habilitar sonido de tecleo solo en cuadros de texto"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:139
msgid "select typing sound"
msgstr "seleccionar sonido de tecleo"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:143
msgid "volume"
msgstr ""

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:147
msgid "open sounds folder"
msgstr "abrir carpeta de sonidos"

#: C:\Users\Mesteranas1\AppData\Roaming\nvda\addons\navSounds\globalPlugins\NavigationSounds\__init__.py:149
msgid "donate"
msgstr "donar"
Binary file modified navsounds/locale/fr/LC_MESSAGES/nvda.mo
Binary file not shown.
Loading

0 comments on commit b6ed448

Please sign in to comment.