[orca] Get the voice for key events from speechgenerator



commit d1085da77d697eb75068764db38614a5f74c7d38
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Jul 19 02:05:32 2016 -0400

    Get the voice for key events from speechgenerator

 src/orca/scripts/default.py         |    7 ++++++-
 src/orca/speech.py                  |    7 ++++---
 src/orca/speech_generator.py        |    2 +-
 src/orca/speechdispatcherfactory.py |    7 +------
 src/orca/speechserver.py            |    2 +-
 5 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 803c4ab..d5a7961 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3736,7 +3736,12 @@ class Script(script.Script):
                 self.phoneticSpellCurrentItem(event.event_string)
                 return True
 
-        speech.speakKeyEvent(event)
+        string = None
+        if event.isPrintableKey():
+            string = event.event_string
+
+        voice = self.speechGenerator.voice(string=string)
+        speech.speakKeyEvent(event, voice)
         return True
 
     def presentMessage(self, fullMessage, briefMessage=None, voice=None, resetStyles=True):
diff --git a/src/orca/speech.py b/src/orca/speech.py
index 559d303..b21e451 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -226,7 +226,7 @@ def speak(content, acss=None, interrupt=True):
         string = " ".join(toSpeak)
         _speak(string, activeVoice, interrupt)
 
-def speakKeyEvent(event):
+def speakKeyEvent(event, acss=None):
     """Speaks a key event immediately.
 
     Arguments:
@@ -238,13 +238,14 @@ def speakKeyEvent(event):
 
     keyname = event.getKeyName()
     lockingStateString = event.getLockingStateString()
+    acss = __resolveACSS(acss)
     msg = "%s %s" % (keyname, lockingStateString)
-    logLine = "SPEECH OUTPUT: '%s'" % msg
+    logLine = "SPEECH OUTPUT: '%s' %s" % (msg, acss)
     debug.println(debug.LEVEL_INFO, logLine, True)
     log.info(logLine)
 
     if _speechserver:
-        _speechserver.speakKeyEvent(event)
+        _speechserver.speakKeyEvent(event, acss)
 
 def speakCharacter(character, acss=None):
     """Speaks a single character immediately.
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 8c250f0..f7068a6 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -2258,7 +2258,7 @@ class SpeechGenerator(generator.Generator):
         voice = acss.ACSS(rv)
         if key in [None, DEFAULT]:
             string = args.get('string', '')
-            if string.isupper():
+            if isinstance(string, str) and string.isupper():
                 voice.update(voices.get(voiceType.get(UPPERCASE)))
 
         return [voice]
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index 151cc53..b9ea2e0 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -499,12 +499,7 @@ class SpeechServer(speechserver.SpeechServer):
                 utilities.adjustForPronunciation(name)
         self.speak(name, acss)
 
-    def speakKeyEvent(self, event):
-        if event.isPrintableKey() and event.event_string.isupper():
-            acss = settings.voices[settings.UPPERCASE_VOICE]
-        else:
-            acss = ACSS(settings.voices[settings.DEFAULT_VOICE])
-
+    def speakKeyEvent(self, event, acss=None):
         event_string = event.getKeyName()
         if orca_state.activeScript:
             event_string = orca_state.activeScript.\
diff --git a/src/orca/speechserver.py b/src/orca/speechserver.py
index 1de1a52..9ea92ff 100644
--- a/src/orca/speechserver.py
+++ b/src/orca/speechserver.py
@@ -139,7 +139,7 @@ class SpeechServer(object):
         """
         pass
 
-    def speakKeyEvent(self, event):
+    def speakKeyEvent(self, event, acss=None):
         """Speaks a key event immediately.
 
         Arguments:


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