diff --git a/src/cthulhu/scripts/web/speech_generator.py b/src/cthulhu/scripts/web/speech_generator.py index 53b6867..824d0c5 100644 --- a/src/cthulhu/scripts/web/speech_generator.py +++ b/src/cthulhu/scripts/web/speech_generator.py @@ -558,8 +558,13 @@ class SpeechGenerator(speech_generator.SpeechGenerator): role = args.get('role', AXObject.get_role(obj)) roleSoundPresentation = _settingsManager.getSetting('roleSoundPresentation') + soundEnabled = _settingsManager.getSetting('enableSound') + roleSoundIcon = None + if roleSoundPresentation != settings.ROLE_SOUND_PRESENTATION_SPEECH_ONLY \ + and soundEnabled: + roleSoundIcon = sound_theme_manager.getManager().getRoleSoundIcon(role) if roleSoundPresentation == settings.ROLE_SOUND_PRESENTATION_SOUND_ONLY \ - and _settingsManager.getSetting('enableSound'): + and soundEnabled and roleSoundIcon: if AXUtilities.is_check_box(obj) \ or AXUtilities.is_check_menu_item(obj) \ or AXUtilities.is_radio_button(obj) \ @@ -678,9 +683,10 @@ class SpeechGenerator(speech_generator.SpeechGenerator): if not _settingsManager.getSetting('enableSound'): return result - roleSoundIcon = sound_theme_manager.getManager().getRoleSoundIcon(role) if roleSoundPresentation == settings.ROLE_SOUND_PRESENTATION_SOUND_ONLY: - return [roleSoundIcon] if roleSoundIcon else [] + if roleSoundIcon: + return [roleSoundIcon] + return result if not roleSoundIcon: return result diff --git a/src/cthulhu/speech_generator.py b/src/cthulhu/speech_generator.py index 618ec8d..4c6b6f3 100644 --- a/src/cthulhu/speech_generator.py +++ b/src/cthulhu/speech_generator.py @@ -666,8 +666,13 @@ class SpeechGenerator(generator.Generator): result = [] role = args.get('role', AXObject.get_role(obj)) roleSoundPresentation = _settingsManager.getSetting('roleSoundPresentation') + soundEnabled = _settingsManager.getSetting('enableSound') + roleSoundIcon = None + if roleSoundPresentation != settings.ROLE_SOUND_PRESENTATION_SPEECH_ONLY \ + and soundEnabled: + roleSoundIcon = sound_theme_manager.getManager().getRoleSoundIcon(role) if roleSoundPresentation == settings.ROLE_SOUND_PRESENTATION_SOUND_ONLY \ - and _settingsManager.getSetting('enableSound'): + and soundEnabled and roleSoundIcon: if AXUtilities.is_check_box(obj) \ or AXUtilities.is_check_menu_item(obj) \ or AXUtilities.is_radio_button(obj) \ @@ -675,10 +680,6 @@ class SpeechGenerator(generator.Generator): or AXUtilities.is_toggle_button(obj) \ or AXUtilities.is_switch(obj): return [] - roleSoundIcon = None - if roleSoundPresentation != settings.ROLE_SOUND_PRESENTATION_SPEECH_ONLY \ - and _settingsManager.getSetting('enableSound'): - roleSoundIcon = sound_theme_manager.getManager().getRoleSoundIcon(role) doNotPresent = [Atspi.Role.UNKNOWN, Atspi.Role.REDUNDANT_OBJECT, @@ -722,7 +723,9 @@ class SpeechGenerator(generator.Generator): result.extend(self.voice(SYSTEM, obj=obj, **args)) if roleSoundPresentation == settings.ROLE_SOUND_PRESENTATION_SOUND_ONLY: - return [roleSoundIcon] if roleSoundIcon else [] + if roleSoundIcon: + return [roleSoundIcon] + return result if result and roleSoundIcon: if roleSoundPresentation == settings.ROLE_SOUND_PRESENTATION_SOUND_AND_SPEECH: