~ubuntu-branches/ubuntu/hardy/gnome-orca/hardy

« back to all changes in this revision

Viewing changes to src/orca/speechdispatcherfactory.py

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2007-07-10 21:54:54 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20070710215454-trky3o11pcc78qg4
Tags: 2.19.5-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
import debug
38
38
import speechserver
39
39
import settings
 
40
import orca
40
41
from acss import ACSS
41
42
from orca_i18n import _
42
43
from speechserver import VoiceFamily
44
45
class SpeechDispatcherVersionError(Exception):
45
46
    """Incompatible version of the Speech Dispatcher Python Interface."""
46
47
 
47
 
 
48
48
class SpeechServer(speechserver.SpeechServer):
49
49
    # See the parent class for documentation.
50
50
 
51
51
    _activeServers = {}
52
52
 
 
53
    KEY_NAMES = {
 
54
        '_':     'underscore',
 
55
        'space': 'space',
 
56
        '"':     'double-quote',
 
57
        }
 
58
 
53
59
    def getFactoryName():
54
60
        return _("Speech Dispatcher")
55
61
    getFactoryName = staticmethod(getFactoryName)
153
159
            if value is not None and current.get(property) != value:
154
160
                method(value)
155
161
                current[property] = value
156
 
        
 
162
 
157
163
    def _speak(self, text, acss, **kwargs):
158
164
        self._apply_acss(acss)
159
165
        self._client.speak(text, **kwargs)
200
206
                      "Speech rate is now %d" % rate)
201
207
        # Translators: This string announces speech rate change.
202
208
        self.speak(decrease and _("slower.") or _("faster."), acss=acss)
203
 
            
 
209
 
204
210
    def _change_default_speech_pitch(self, decrease=False):
205
211
        acss = settings.voices[settings.DEFAULT_VOICE]
206
212
        delta = settings.speechPitchDelta * (decrease and -1 or +1)
245
251
    def speakCharacter(self, character, acss=None):
246
252
        self._client.char(character)
247
253
 
 
254
    def speakKeyEvent(self, event_string, type):
 
255
        if type == orca.KeyEventType.PRINTABLE:
 
256
            # We currently only handle printable characters by Speech
 
257
            # Dispatcher's KEY command.  For other keys, such as Ctrl, Shift
 
258
            # etc. we prefer Orca's verbalization.
 
259
            if event_string.decode("UTF-8").isupper():
 
260
                voice = settings.voices[settings.UPPERCASE_VOICE]
 
261
            else:
 
262
                voice = settings.voices[settings.DEFAULT_VOICE]
 
263
            self._apply_acss(voice)
 
264
            self._client.key(self.KEY_NAMES.get(event_string, event_string))
 
265
        else:
 
266
            return super(SpeechServer, self).speakKeyEvent(event_string, type)
 
267
 
248
268
    def increaseSpeechRate(self, step=5):
249
269
        self._change_default_speech_rate()
250
270
 
253
273
 
254
274
    def increaseSpeechPitch(self, step=0.5):
255
275
        self._change_default_speech_pitch()
256
 
        
 
276
 
257
277
    def decreaseSpeechPitch(self, step=0.5):
258
278
        self._change_default_speech_pitch(decrease=True)
259
279