diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-12-14 18:48:34 (GMT) |
---|---|---|
committer | Gary Martin <gary@garycmartin.com> | 2012-12-16 18:56:15 (GMT) |
commit | a7af1d2a9289191e017d145687e8c973fad1ea42 (patch) | |
tree | faa3bc749126046ed187ec5120bd6f0a37fa4932 | |
parent | 44a3dc7c285f3f318d9bc4461151a2b9620bac07 (diff) |
Clock goes back to the speaking-mode SL #4079
This PATCH is just a workaround to the real problem:
Clock is using gst 0.11 but we have installed the 'espeak' plugin
for Gst 1.0 because we need that version for the shell
itself. So, Clock does not find the proper plugin and tries to
use the 'espeak' command directily but it fails as well because a
'portaudio' lib issue.
This PATCH makes 'espeak' to create a WAV file in a temporary file and
then plays it with the command 'playwave'. It's the same idea used in
Speak, with the difference than Speak uses gstreamer to play the wav
file.
This workaround will not be necessary when Clock uses Gtk3 and Gst
1.0.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
-rwxr-xr-x | speaker.py | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -14,6 +14,7 @@ Controls the espeak program available on the OLPC XO laptop. import sys import os +import tempfile from gettext import gettext as _ @@ -51,12 +52,28 @@ class Speaker: # http://espeak.sourceforge.net/languages.html to see if your language is supported. VOICE = _("en") + # Temporary file to save the 'espeak -w' output and then play it + # with 'playwave' command + WAV_TEMP_FILE = tempfile.mktemp() + + # 'espeak' command to generate the wav file to be played with 'playwave' + ESPEAK_COMMAND = 'espeak -p%s -s%s -g%s -v%s "%s" -w %s' + + # 'playwave' command that plays the wav generated by 'espeak' + PLAYWAVE_COMMAND = 'playwave %s' % WAV_TEMP_FILE def speak(self, text): """Speaks aloud the given text. """ text = text.replace("\"", "\\\"") - child = os.popen("espeak -p%s -s%s -g%s -v%s \"%s\"" % (Speaker.PITCH, Speaker.SPEED, Speaker.WORD_GAP, Speaker.VOICE, text)) + child = os.popen(Speaker.ESPEAK_COMMAND % ( + Speaker.PITCH, Speaker.SPEED, Speaker.WORD_GAP, Speaker.VOICE, + text, Speaker.WAV_TEMP_FILE)) + data = child.read() + child.close() + + # This is a workaround for SL #4079 + child = os.popen(Speaker.PLAYWAVE_COMMAND) data = child.read() child.close() |