[Sugar-devel] [PATCH] Handle missing gst-plugins-espeak gracefully - SL#3345

godiard at sugarlabs.org godiard at sugarlabs.org
Tue Apr 24 09:25:19 EDT 2012


From: Gonzalo Odiard <godiard at gmail.com>

The text-to-speech support in Sugar (jarabe.model.speech) depends on
gst-plugins-espeak [1]. While Sugar continues to work properly in the
absence of gst-plugins-espeak, loading the corresponding components
(keyboard shortcut handler and Frame device icon) currently fails hard
and produces a traceback in the log. However TTS support is entirely
optional and the traceback suggests an unhandled system failure rather
than optional support not being available. Fix this by catching the
exception when accessing the SpeechManager and logging a warning
instead.

[1] https://wiki.sugarlabs.org/go/Activity_Team/gst-plugins-espeak

Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
---
 extensions/deviceicon/speech.py |    7 +++++--
 extensions/globalkey/speech.py  |    3 +--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/extensions/deviceicon/speech.py b/extensions/deviceicon/speech.py
index 6b8f915..889d509 100644
--- a/extensions/deviceicon/speech.py
+++ b/extensions/deviceicon/speech.py
@@ -14,6 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
+import logging
 from gettext import gettext as _
 
 import glib
@@ -31,7 +32,6 @@ from sugar.graphics import style
 from jarabe.frame.frameinvoker import FrameWidgetInvoker
 from jarabe.model import speech
 
-
 _ICON_NAME = 'microphone'
 
 
@@ -145,4 +145,7 @@ class SpeechPalette(Palette):
 
 
 def setup(tray):
-    tray.add_device(SpeechDeviceView())
+    try:
+        tray.add_device(SpeechDeviceView())
+    except:
+        logging.warning('Text to speech no available. Missing dependencies')
diff --git a/extensions/globalkey/speech.py b/extensions/globalkey/speech.py
index 2879b69..e47c778 100644
--- a/extensions/globalkey/speech.py
+++ b/extensions/globalkey/speech.py
@@ -14,10 +14,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-from jarabe.model import speech
-
 BOUND_KEYS = ['<alt><shift>s']
 
+from jarabe.model import speech
 
 def handle_key_press(key):
     manager = speech.get_speech_manager()
-- 
1.7.7.6



More information about the Sugar-devel mailing list