orca r4433 - in trunk: . src/orca



Author: wwalker
Date: Mon Jan 19 15:46:14 2009
New Revision: 4433
URL: http://svn.gnome.org/viewvc/orca?rev=4433&view=rev

Log:
Fix for bug #562060 - speech should speak multicase strings as words


Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/orca/gnomespeechfactory.py
   trunk/src/orca/orca-setup.glade
   trunk/src/orca/orca_gui_prefs.py
   trunk/src/orca/settings.py
   trunk/src/orca/speech.py
   trunk/src/orca/speechdispatcherfactory.py

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Mon Jan 19 15:46:14 2009
@@ -4,6 +4,8 @@
 
 * Fix for bug #535221 - Automatic shortcut information spoken
 
+* Fix for bug #562060 - Speech should speak multi case strings as words
+
 * Fix for bug #562327 - Desktop tutor message order problem
 
 * Fix for bug #563171 - src/orca/flat_review.py:getZonesFromText

Modified: trunk/src/orca/gnomespeechfactory.py
==============================================================================
--- trunk/src/orca/gnomespeechfactory.py	(original)
+++ trunk/src/orca/gnomespeechfactory.py	Mon Jan 19 15:46:14 2009
@@ -894,8 +894,6 @@
             return -1
 
         text = self.__addVerbalizedPunctuation(text)
-        if orca_state.activeScript and orca_state.usePronunciationDictionary:
-            text = orca_state.activeScript.adjustForPronunciation(text)
 
         try:
             # [[[TODO: WDW - back this stop out for now.  The problem is

Modified: trunk/src/orca/orca-setup.glade
==============================================================================
--- trunk/src/orca/orca-setup.glade	(original)
+++ trunk/src/orca/orca-setup.glade	Mon Jan 19 15:46:14 2009
@@ -1387,6 +1387,26 @@
 		      </child>
 
 		      <child>
+			<widget class="GtkCheckButton" id="speakMultiCaseAsWordsCheckButton">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">Speak multicase strings as wor_ds</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">True</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			  <signal name="toggled" handler="speakMultiCaseStringsToggled" last_modification_time="Sun, 23 Nov 2008 18:38:04 GMT"/>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
 			<widget class="GtkCheckButton" id="speakTutorialMessagesCheckButton">
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>

Modified: trunk/src/orca/orca_gui_prefs.py
==============================================================================
--- trunk/src/orca/orca_gui_prefs.py	(original)
+++ trunk/src/orca/orca_gui_prefs.py	Mon Jan 19 15:46:14 2009
@@ -1485,6 +1485,8 @@
 
         self.get_widget("speakBlankLinesCheckButton").set_active(\
             prefs["speakBlankLines"])
+        self.get_widget("speakMultiCaseAsWordsCheckButton").set_active(\
+            prefs["speakMultiCaseStringsAsWords"])
         self.get_widget("speakTutorialMessagesCheckButton").set_active(\
             prefs["enableTutorialMessages"])
 
@@ -2478,6 +2480,18 @@
 
         self.prefsDict["speakBlankLines"] = widget.get_active()
 
+    def speakMultiCaseStringsToggled(self, widget):
+        """Signal handler for the "toggled" signal for the
+           speakMultiCaseAsWordsCheckButton GtkCheckButton widget. The user has
+           [un]checked the checkbox.
+           Set the 'speakMultiCaseStringsAsWords' preference to the new value.
+
+        Arguments:
+        - widget: the component that generated the signal.
+        """
+
+        self.prefsDict["speakMultiCaseStringsAsWords"] = widget.get_active()
+
     def speakTutorialMessagesToggled(self, widget):
         """Signal handler for the "toggled" signal for the
            speakTutorialMessagesCheckButton GtkCheckButton widget.

Modified: trunk/src/orca/settings.py
==============================================================================
--- trunk/src/orca/settings.py	(original)
+++ trunk/src/orca/settings.py	Mon Jan 19 15:46:14 2009
@@ -162,6 +162,7 @@
     "sayAllStyle",
     "keyboardLayout",
     "speakBlankLines",
+    "speakMultiCaseStringsAsWords",
     "enabledSpokenTextAttributes",
     "enabledBrailledTextAttributes",
     "textAttributesBrailleIndicator",
@@ -629,6 +630,10 @@
 #
 speakBlankLines         = True
 
+# if True, process multi case strings as words.
+#
+speakMultiCaseStringsAsWords = False
+
 # If True, reads all the table cells in the current row rather than just
 # the current one.
 #

Modified: trunk/src/orca/speech.py
==============================================================================
--- trunk/src/orca/speech.py	(original)
+++ trunk/src/orca/speech.py	Mon Jan 19 15:46:14 2009
@@ -29,6 +29,7 @@
 import logging
 log = logging.getLogger("speech")
 
+import re
 import time
 
 import chnames
@@ -45,6 +46,13 @@
 #
 _speechserver = None
 
+# regular expressions for multiCaseStrings
+#
+multiCaseReg1 = re.compile("([a-z]+)([A-Z][a-z]+)")
+multiCaseReg2 = re.compile("([a-z]+)([A-Z]+)")
+multiCaseReg3 = re.compile("([A-Z]{2}[A-Z]+)([a-z]+)")
+multiCaseReg4 = re.compile("([A-Z])([A-Z][a-z]+)")
+
 def getSpeechServerFactories():
     """Imports all known SpeechServer factory modules.  Returns a list
     of modules that implement the getSpeechServers method, which
@@ -154,6 +162,13 @@
     if settings.silenceSpeech:
         return
 
+    if settings.speakMultiCaseStringsAsWords:
+        text = _processMultiCaseString(text)
+    if orca_state.activeScript and orca_state.usePronunciationDictionary:
+        text = orca_state.activeScript.adjustForPronunciation(text)
+    if settings.speakMultiCaseStringsAsWords:
+        text = _processMultiCaseString(text)
+
     logLine = "SPEECH OUTPUT: '" + text + "'"
     debug.println(debug.LEVEL_INFO, logLine)
     log.info(logLine)
@@ -245,8 +260,19 @@
 
     if settings.silenceSpeech:
         return
-
-    for utterance in utterances:
+    i = 0
+    length = len(utterances)
+    while ( i < length ):
+        utterance = utterances[i]
+        if settings.speakMultiCaseStringsAsWords:
+            utterance = _processMultiCaseString(utterance)
+        if settings.speakMultiCaseStringsAsWords:
+            utterances[i] = _processMultiCaseString(utterance)
+            utterance = utterances[i] 
+        if settings.speakMultiCaseStringsAsWords:
+            utterance = _processMultiCaseString(utterance)
+        i = i + 1
+        
         logLine = "SPEECH OUTPUT: '" + utterance + "'"
         debug.println(debug.LEVEL_INFO, logLine)
         log.info(logLine)
@@ -345,3 +371,14 @@
                 server.shutdown()
             except:
                 debug.printException(debug.LEVEL_OFF)
+
+def _processMultiCaseString(string):
+    """Helper function, applies the regexes to split multiCaseStrings
+    to multiple words.
+    """
+
+    string = multiCaseReg1.sub('\\1 \\2', string)
+    string = multiCaseReg2.sub('\\1 \\2', string)
+    string = multiCaseReg3.sub('\\1 \\2', string)    
+    string = multiCaseReg4.sub('\\1 \\2', string)
+    return string

Modified: trunk/src/orca/speechdispatcherfactory.py
==============================================================================
--- trunk/src/orca/speechdispatcherfactory.py	(original)
+++ trunk/src/orca/speechdispatcherfactory.py	Mon Jan 19 15:46:14 2009
@@ -44,7 +44,6 @@
 import speechserver
 import settings
 import orca
-import orca_state
 from acss import ACSS
 from orca_i18n import _
 
@@ -327,8 +326,7 @@
     def speak(self, text=None, acss=None, interrupt=True):
         #if interrupt:
         #    self._cancel()
-        if orca_state.activeScript and orca_state.usePronunciationDictionary:
-            text = orca_state.activeScript.adjustForPronunciation(text)
+
         if text:
             self._speak(text, acss)
 



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