Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Speak.activity/face.py
diff options
context:
space:
mode:
Diffstat (limited to 'Speak.activity/face.py')
-rw-r--r--Speak.activity/face.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/Speak.activity/face.py b/Speak.activity/face.py
index 7dbaa77..e77fe8f 100644
--- a/Speak.activity/face.py
+++ b/Speak.activity/face.py
@@ -34,6 +34,7 @@ import logging
import gtk
import gobject
import pango
+import cjson
from gettext import gettext as _
# try:
@@ -59,6 +60,8 @@ import voice
import fft_mouth
import waveform_mouth
+logger = logging.getLogger('speak')
+
PITCH_MAX = 100
RATE_MAX = 100
FACE_PAD = 2
@@ -71,6 +74,38 @@ class Status:
self.eyes = [eye.Eye] * 2
self.mouth = mouth.Mouth
+ def serialize(self):
+ eyes = { eye.Eye : 1,
+ glasses.Glasses : 2 }
+ mouths = { mouth.Mouth : 1,
+ fft_mouth.FFTMouth : 2,
+ waveform_mouth.WaveformMouth : 3 }
+
+ return cjson.encode({
+ 'voice' : { 'language' : self.voice.language,
+ 'gender' : self.voice.gender,
+ 'name' : self.voice.name },
+ 'pitch' : self.pitch,
+ 'rate' : self.rate,
+ 'eyes' : [eyes[i] for i in self.eyes],
+ 'mouth' : mouths[self.mouth] })
+
+ def deserialize(self, buf):
+ eyes = { 1: eye.Eye,
+ 2: glasses.Glasses }
+ mouths = { 1: mouth.Mouth,
+ 2: fft_mouth.FFTMouth,
+ 3: waveform_mouth.WaveformMouth }
+
+ data = cjson.decode(buf)
+ self.voice.language = data['voice']['language']
+ self.voice.gender = data['voice']['gender']
+ self.voice.name = data['voice']['name']
+ self.pitch = data['pitch']
+ self.rate = data['rate']
+ self.eyes = [eyes[i] for i in data['eyes']]
+ self.mouth = mouths[data['mouth']]
+
class View(gtk.EventBox):
def __init__(self, fill_color=style.COLOR_BUTTON_GREY):
gtk.EventBox.__init__(self)
@@ -154,7 +189,7 @@ class View(gtk.EventBox):
if self._audio is None:
return
- logging.debug('%s: %s' % (self.status.voice.name, something))
+ logger.debug('%s: %s' % (self.status.voice.name, something))
pitch = int(self.status.pitch)
rate = int(self.status.rate)