Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-04-29 17:37:45 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-04-29 17:37:45 (GMT)
commit5c85d05a3add414b224e7880aae82736c098e80b (patch)
treef4432338274ee7c3112f51a0494361b742bf167c
parentb419cad17826b53940deb8c95935035b99e0e836 (diff)
Pronounce gettext strings in native language
-rw-r--r--Speak.activity/activity.py13
-rw-r--r--Speak.activity/brain.py12
-rw-r--r--Speak.activity/face.py16
-rw-r--r--Speak.activity/voice.py7
4 files changed, 32 insertions, 16 deletions
diff --git a/Speak.activity/activity.py b/Speak.activity/activity.py
index 5abd9a0..1537d79 100644
--- a/Speak.activity/activity.py
+++ b/Speak.activity/activity.py
@@ -170,7 +170,8 @@ class SpeakActivity(SharedActivity):
# say hello to the user
presenceService = presenceservice.get_instance()
xoOwner = presenceService.get_owner()
- self.face.say(_("Hello %s. Type something.") % xoOwner.props.nick)
+ self.face.say_notification(_("Hello %s. Type something.") \
+ % xoOwner.props.nick)
def resume_instance(self, file_path):
cfg = cjson.decode(file(file_path, 'r').read())
@@ -276,15 +277,15 @@ class SpeakActivity(SharedActivity):
def voice_changed_cb(self, combo):
self.face.status.voice = combo.props.value
- self.face.say(self.face.status.voice.friendlyname)
+ self.face.say_notification(self.face.status.voice.friendlyname)
def pitch_adjusted_cb(self, get, data=None):
self.face.status.pitch = get.value
- self.face.say(_("pitch adjusted"))
+ self.face.say_notification(_("pitch adjusted"))
def rate_adjusted_cb(self, get, data=None):
self.face.status.rate = get.value
- self.face.say(_("rate adjusted"))
+ self.face.say_notification(_("rate adjusted"))
def make_face_bar(self):
facebar = gtk.Toolbar()
@@ -328,7 +329,7 @@ class SpeakActivity(SharedActivity):
# this SegFaults: self.face.say(combo.get_active_text())
if not quiet:
- self.face.say(_("mouth changed"))
+ self.face.say_notification(_("mouth changed"))
def eyes_changed_cb(self, ignored, quiet):
if self.numeyesadj is None:
@@ -340,7 +341,7 @@ class SpeakActivity(SharedActivity):
# this SegFaults: self.face.say(self.eye_shape_combo.get_active_text())
if not quiet:
- self.face.say(_("eyes changed"))
+ self.face.say_notification(_("eyes changed"))
def _combo_changed_cb(self, combo):
# when a new item is chosen, make sure the text is selected
diff --git a/Speak.activity/brain.py b/Speak.activity/brain.py
index 16ac74b..20000a9 100644
--- a/Speak.activity/brain.py
+++ b/Speak.activity/brain.py
@@ -39,9 +39,9 @@ BOTS = {
'predicates': { 'name': 'Alice',
'master': 'the Sugar Community' } } }
-DEFAULT = voice.defaultVoice()
+DEFAULT = voice.DEFAULT
if not BOTS.has_key(DEFAULT):
- DEFAULT = _('English')
+ DEFAULT = voice.allVoices()[_('English')]
class Toolbar(gtk.Toolbar):
def __init__(self, activity):
@@ -80,9 +80,9 @@ class Toolbar(gtk.Toolbar):
hello = _("Hello, I'am a robot \"%s\". Ask me any question.") \
% BOTS[voice]['name']
hello += ' ' + sorry
- self.activity.face.say(hello)
+ self.activity.face.say_notification(hello)
elif sorry:
- self.activity.face.say(sorry)
+ self.activity.face.say_notification(sorry)
old_cursor = self.activity.get_cursor()
self.activity.set_cursor(gtk.gdk.WATCH)
@@ -96,7 +96,7 @@ class Toolbar(gtk.Toolbar):
def update_voice(self):
voice = self.activity.voice_combo.props.value.friendlyname
- new_voice = BOTS.has_key(voice) and voice or DEFAULT
+ new_voice = BOTS.has_key(voice) and voice or DEFAULT.friendlyname
if voice != new_voice:
self.activity.change_voice(new_voice, True)
@@ -108,7 +108,7 @@ class Toolbar(gtk.Toolbar):
if not self._kernels.has_key(new_voice):
self._load_brain(new_voice, (voice != new_voice) and sorry or '')
elif voice != new_voice:
- self.activity.face.say(sorry)
+ self.activity.face.say_notification(sorry)
def respond(self, text):
voice = self.voices.combo.props.value
diff --git a/Speak.activity/face.py b/Speak.activity/face.py
index e595a5e..ffb88c3 100644
--- a/Speak.activity/face.py
+++ b/Speak.activity/face.py
@@ -43,7 +43,7 @@ FACE_PAD = 2
class Status:
def __init__(self):
- self.voice = voice.defaultVoice()
+ self.voice = voice.DEFAULT
self.pitch = audio.PITCH_DEFAULT
self.rate = audio.RATE_DEFAULT
self.eyes = [eye.Eye] * 2
@@ -81,6 +81,15 @@ class Status:
return self
+ def clone(self):
+ new = Status()
+ new.voice = self.voice
+ new.pitch = self.pitch
+ new.rate = self.rate
+ new.eyes = self.eyes
+ new.mouth = self.mouth
+ return new
+
class View(gtk.EventBox):
def __init__(self, fill_color=style.COLOR_BUTTON_GREY):
gtk.EventBox.__init__(self)
@@ -163,6 +172,11 @@ class View(gtk.EventBox):
def say(self, something):
self._audio.speak(self._peding or self.status, something)
+ def say_notification(self, something):
+ status = (self._peding or self.status).clone()
+ status.voice = voice.DEFAULT
+ self._audio.speak(status, something)
+
def shut_up(self):
self._audio.stop_sound_device()
diff --git a/Speak.activity/voice.py b/Speak.activity/voice.py
index 38984c6..ecd3d5d 100644
--- a/Speak.activity/voice.py
+++ b/Speak.activity/voice.py
@@ -72,6 +72,7 @@ expectedVoiceNames = [
]
_allVoices = {}
+DEFAULT = None
class Voice:
def __init__(self, language, name):
@@ -112,9 +113,7 @@ def allVoices():
_allVoices[voice.friendlyname] = voice
return _allVoices
-
-
-def defaultVoice():
+def _defaultVoice():
"""Try to figure out the default voice, from the current locale ($LANG).
Fall back to espeak's voice called Default."""
@@ -143,3 +142,5 @@ def defaultVoice():
print "Best voice for LANG %s seems to be %s %s" % (lang, best.language, best.friendlyname)
return best
+
+DEFAULT = _defaultVoice()