Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2012-05-05 15:01:27 (GMT)
committer Gary Martin <gary@garycmartin.com>2012-05-05 15:01:27 (GMT)
commit7fffe276a0631aef5a60841974645dd8f665d8d9 (patch)
tree06639f1f138be84bfba612c0cd8b34a1a1348d9e
parente5a9c92b8187ae79b7986234e3fed55d05711950 (diff)
Default to gstreamer espeak plugin, if available, or use espeak command for old Sugar build support SL#3453
-rwxr-xr-xclock.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/clock.py b/clock.py
index 825fb93..1219aee 100755
--- a/clock.py
+++ b/clock.py
@@ -70,6 +70,7 @@ import pygtk
import gtk
from gtk import gdk
import pango
+import gst
OLD_TOOLBAR = False
try:
@@ -431,9 +432,22 @@ class ClockActivity(activity.Activity):
def _do_speak_time(self):
"""Speak aloud the current time.
"""
- if self._time_speaker is None:
- self._time_speaker = Speaker()
- self._time_speaker.speak(self._untag(self._time_in_letters))
+
+ def gstmessage_cb(bus, message, pipe):
+ if message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
+ pipe.set_state(gst.STATE_NULL)
+
+ pipeline = 'espeak text="%s" ! autoaudiosink' % self._untag(self._time_in_letters)
+ try:
+ pipe = gst.parse_launch(pipeline)
+ bus = pipe.get_bus()
+ bus.add_signal_watch()
+ bus.connect('message', gstmessage_cb, pipe)
+ pipe.set_state(gst.STATE_PLAYING)
+ except:
+ if self._time_speaker is None:
+ self._time_speaker = Speaker()
+ self._time_speaker.speak(self._untag(self._time_in_letters))
def _untag(self, text):
"""Remove all the tags (pango markup) from a text.