From c02aca65850836d4a8bcee1e730e21927e12051c Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 28 Feb 2012 22:18:16 +0000 Subject: Fix pronunciation of unicode strings; keep history in unicode (Gonzalo Odiard) --- diff --git a/TODO b/TODO index d053206..38e7762 100644 --- a/TODO +++ b/TODO @@ -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') -- cgit v0.9.1