diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-02-28 22:18:16 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-02-28 22:18:37 (GMT) |
commit | c02aca65850836d4a8bcee1e730e21927e12051c (patch) | |
tree | 47b15dfe1c5b24afa6165be31d8a37796bde98ce | |
parent | a0f14888003c812b3fa95d8db30233943a31b0d5 (diff) |
Fix pronunciation of unicode strings; keep history in unicode (Gonzalo Odiard)
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | activity.py | 10 | ||||
-rw-r--r-- | espeak_gst.py | 3 |
3 files changed, 10 insertions, 5 deletions
@@ -1,3 +1,5 @@ +- switch to standard JSON library + - collaboration - if performance is okay, should show multiple faces - one for each person - if not, then just share settings and let any person type diff --git a/activity.py b/activity.py index ee00da9..3e85c24 100644 --- a/activity.py +++ b/activity.py @@ -210,16 +210,18 @@ class SpeakActivity(SharedActivity): self.eye_shape_combo.select(status.eyes[0]) self.numeyesadj.value = len(status.eyes) - self.entry.props.text = cfg['text'] + self.entry.props.text = cfg['text'].encode('utf-8', 'ignore') for i in cfg['history']: - self.entrycombo.append_text(i) + self.entrycombo.append_text(i.encode('utf-8', 'ignore')) self.new_instance() def save_instance(self, file_path): cfg = {'status': self.face.status.serialize(), - 'text': self.entry.props.text, - 'history': map(lambda i: i[0], self.entrycombo.get_model())} + 'text': unicode(self.entry.props.text, 'utf-8', 'ignore'), + 'history': [unicode(i[0], 'utf-8', 'ignore') \ + for i in self.entrycombo.get_model()], + } file(file_path, 'w').write(cjson.encode(cfg)) def share_instance(self, connection, is_initiator): diff --git a/espeak_gst.py b/espeak_gst.py index 9c72994..b4af2c8 100644 --- a/espeak_gst.py +++ b/espeak_gst.py @@ -26,7 +26,8 @@ RATE_MAX = 200 class AudioGrabGst(espeak.BaseAudioGrab): def speak(self, status, text): # XXX workaround for http://bugs.sugarlabs.org/ticket/1801 - if not [i for i in text if i.isalnum()]: + if not [i for i in text \ + if unicode(i, 'utf-8', errors='ignore').isalnum()]: return self.make_pipeline('espeak name=espeak ! wavenc') |