[orca] Provide support to cycle amongst speech-dispatcher's capitalization presentation options



commit a5a08c62fd7239688185b0881f88e1096cd812a0
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Nov 30 15:28:37 2012 -0500

    Provide support to cycle amongst speech-dispatcher's capitalization presentation options

 src/orca/common_keyboardmap.py      |    2 +
 src/orca/scripts/default.py         |  111 +++++++++++++++++++++++++++++++++++
 src/orca/settings.py                |    7 ++
 src/orca/speech.py                  |    8 +++
 src/orca/speechdispatcherfactory.py |    4 +
 src/orca/speechserver.py            |    4 +
 6 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index 0cfa43e..71d41a4 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -164,6 +164,8 @@ keymap = (
     #                                                                   #
     #####################################################################
 
+    ("", defaultModifierMask, NO_MODIFIER_MASK,
+    "cycleCapitalizationStyleHandler"),
 
     ("", defaultModifierMask, NO_MODIFIER_MASK,
     "cycleDebugLevelHandler"),
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 0faac01..be5deda 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -875,6 +875,21 @@ class Script(script.Script):
                 #
                 _("Cycles to the next speaking of punctuation level."))
 
+        self.inputEventHandlers["cycleCapitalizationStyleHandler"] = \
+            input_event.InputEventHandler(
+                Script.cycleCapitalizationStyle,
+                # Translators: Orca uses Speech Dispatcher to present content
+                # to users via text-to-speech. Speech Dispatcher has a feature
+                # to control how capital letters are presented: Do nothing at
+                # all, say the word 'capital' prior to presenting a capital
+                # letter, or play a tone which Speech Dispatcher refers to as
+                # a sound 'icon'. This string to be translated refers to an
+                # Orca command which makes it possible for users to quickly
+                # cycle amongst these alternatives without having to get into
+                # a GUI.
+                #
+                _("Cycles to the next capitalization style."))
+
         self.inputEventHandlers["cycleKeyEchoHandler"] = \
             input_event.InputEventHandler(
                 Script.cycleKeyEcho,
@@ -2745,6 +2760,94 @@ class Script(script.Script):
         speech.updatePunctuationLevel()
         return True
 
+    def cycleCapitalizationStyle(self, inputEvent=None):
+        """ Cycle through the speech-dispatcher capitalization styles. """
+
+        currentStyle = _settingsManager.getSetting('capitalizationStyle')
+        if currentStyle == settings.CAPITALIZATION_STYLE_NONE:
+            newStyle = settings.CAPITALIZATION_STYLE_SPELL
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # full/verbose output presented in response to the use of an
+            # Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            full = _("Capitalization style set to spell.")
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # brief/non-verbose output presented in response to the use of
+            # an Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            brief = C_("capitalization style", "spell")
+        elif currentStyle == settings.CAPITALIZATION_STYLE_SPELL:
+            newStyle = settings.CAPITALIZATION_STYLE_ICON
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # full/verbose output presented in response to the use of an
+            # Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            full = _("Capitalization style set to icon.")
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # brief/non-verbose output presented in response to the use of
+            # an Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            brief = C_("capitalization style", "icon")
+        else:
+            newStyle = settings.CAPITALIZATION_STYLE_NONE
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # full/verbose output presented in response to the use of an
+            # Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            full = _("Capitalization style set to none.")
+            # Translators: Orca uses Speech Dispatcher to present content
+            # to users via text-to-speech. Speech Dispatcher has a feature
+            # to control how capital letters are presented: Do nothing at
+            # all, say the word 'capital' prior to presenting a capital
+            # letter, or play a tone which Speech Dispatcher refers to as
+            # a sound 'icon'. This string to be translated refers to the
+            # brief/non-verbose output presented in response to the use of
+            # an Orca command which makes it possible for users to quickly
+            # cycle amongst these alternatives without having to get into
+            # a GUI.
+            #
+            brief = C_("capitalization style", "none")
+
+        _settingsManager.setSetting('capitalizationStyle', newStyle)
+        self.presentMessage(full, brief)
+        speech.updateCapitalizationStyle()
+        return True
+
     def cycleKeyEcho(self, inputEvent=None):
         (newKey, newWord, newSentence) = (False, False, False)
         key = _settingsManager.getSetting('enableKeyEcho')
@@ -5548,6 +5651,11 @@ class Script(script.Script):
             briefMessage = fullMessage
 
         if _settingsManager.getSetting('enableSpeech'):
+            currentCapStyle = _settingsManager.getSetting('capitalizationStyle')
+            _settingsManager.setSetting(
+                'capitalizationStyle', settings.CAPITALIZATION_STYLE_NONE)
+            speech.updateCapitalizationStyle()
+
             if _settingsManager.getSetting('messageVerbosityLevel') \
                     == settings.VERBOSITY_LEVEL_BRIEF:
                 message = briefMessage
@@ -5557,6 +5665,9 @@ class Script(script.Script):
                 voice = voice or self.voices.get(settings.SYSTEM_VOICE)
                 speech.speak(message, voice)
 
+            _settingsManager.setSetting('capitalizationStyle', currentCapStyle)
+            speech.updateCapitalizationStyle()
+
         if (_settingsManager.getSetting('enableBraille') \
              or _settingsManager.getSetting('enableBrailleMonitor')) \
            and _settingsManager.getSetting('enableFlashMessages'):
diff --git a/src/orca/settings.py b/src/orca/settings.py
index f474744..fb5a3dd 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -210,6 +210,13 @@ SAYALL_STYLE_LINE     = 0
 SAYALL_STYLE_SENTENCE = 1
 sayAllStyle = SAYALL_STYLE_SENTENCE
 
+# Speech Dispatcher capitalization styles.
+CAPITALIZATION_STYLE_NONE  = "none"
+CAPITALIZATION_STYLE_SPELL = "spell"
+CAPITALIZATION_STYLE_ICON = "icon"
+capitalizationStyle = CAPITALIZATION_STYLE_NONE
+
+
 # The absolue amount to change the speech rate when
 # increasing or decreasing speech.  This is a numerical
 # value that represents an ACSS rate value.
diff --git a/src/orca/speech.py b/src/orca/speech.py
index feca4b8..20455a2 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -304,7 +304,15 @@ def stop():
     if _speechserver:
         _speechserver.stop()
 
+def updateCapitalizationStyle(script=None, inputEvent=None):
+    if _speechserver:
+        _speechserver.updateCapitalizationStyle()
+    else:
+        logLine = "SPEECH OUTPUT: 'capitalization style' updated"
+        debug.println(debug.LEVEL_INFO, logLine)
+        log.info(logLine)
 
+    return True
 
 def updatePunctuationLevel(script=None, inputEvent=None):
     """ Punctuation level changed, inform this speechServer. """
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index 30f8644..060eab5 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -197,6 +197,10 @@ class SpeechServer(speechserver.SpeechServer):
         mode = self._PUNCTUATION_MODE_MAP[settings.verbalizePunctuationStyle]
         client.set_punctuation(mode)
 
+    def updateCapitalizationStyle(self):
+        """Updates the capitalization style used by the speech server."""
+        self._client.set_cap_let_recogn(settings.capitalizationStyle)
+
     def updatePunctuationLevel(self):
         """ Punctuation level changed, inform this speechServer. """
         mode = self._PUNCTUATION_MODE_MAP[settings.verbalizePunctuationStyle]
diff --git a/src/orca/speechserver.py b/src/orca/speechserver.py
index d66527e..5667950 100644
--- a/src/orca/speechserver.py
+++ b/src/orca/speechserver.py
@@ -280,6 +280,10 @@ class SpeechServer(object):
         """
         pass
 
+    def updateCapitalizationStyle(self):
+        """Updates the capitalization style used by the speech server."""
+        pass
+
     def updatePunctuationLevel(self):
         """Punctuation level changed, inform this speechServer."""
         pass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]