Hi,

I am new to Python so excuse the code but this patch allows
the user to specify a program to run with the speak plugin
rather than using Festival.  I personally use Cepstral but
there are other engines available as well, most which can
be fed via the commandline.

One thing I haven't been able to figure out with this
plugin, in the menu handler, it's picking up event
movement, IE with up and down but when the user hits
rightarrow to enter a menu, it doesn't read the subsequent
selection.  The user needs to move down and back up again. 
Not sure how to fix this.

Shane

Index: src/plugins/speak.py
===================================================================
--- src/plugins/speak.py        (revision 11144)
+++ src/plugins/speak.py        (working copy)
@@ -1,6 +1,6 @@
 # -*- coding: iso-8859-1 -*-
 # -----------------------------------------------------------------------
-# speak.py - Festival Text-to-Speech plugin for Freevo 1.x
+# speak.py - Text-to-Speech plugin for Freevo 1.x
 # -----------------------------------------------------------------------
 #
 # Notes:
@@ -28,15 +28,18 @@
 # -----------------------------------------------------------------------
 
 import types
-try:
-    import festival
-except ImportError:
-    print String(_('ERROR')+': '+_('You need PyFest')+' 
(http://users.wpi.edu/~squirrel/programs/others/) '+_('to run the speak 
plugin.'))
+import os
 
 from time import localtime, strftime
 
 import config
 
+try:
+    if config.SPEAK_OUTPUT is None or config.SPEAK_OUTPUT == 'festival':
+     import festival
+except ImportError:
+    print String(_('ERROR')+': '+_('You need PyFest')+' 
(http://users.wpi.edu/~squirrel/programs/others/) '+_('to run the speak 
plugin.'))
+
 from plugin import DaemonPlugin
 from util.tv_util import get_chan_displayname
 
@@ -46,7 +49,7 @@
 
 class PluginInterface(DaemonPlugin):
     """
-    Speak context info through Festival Text-to-Speech engine
+    Speak context info through a Text-to-Speech engine
 
     @requires: festival installed and configured U{http://www.cstr.ed.ac.uk/}
 
@@ -71,10 +74,15 @@
     def __init__(self):
         """Initalize 'speak' plugin."""
         DaemonPlugin.__init__(self)
-        # Open socket to festival server at port 1314
-        self.fest = festival.open()
-        # We want non-blocking behavior
-        self.fest.block(False)
+        if config.SPEAK_OUTPUT is None:
+         self.output = 'festival'
+        else:
+         self.output = config.SPEAK_OUTPUT
+        if self.output == 'festival':
+         # Open socket to festival server at port 1314
+         self.fest = festival.open()
+         # We want non-blocking behavior
+         self.fest.block(False)
         # Set welcome/shutdown messages
         if config.SPEAK_WELCOME:
             self.welcome_msg = config.SPEAK_WELCOME
@@ -102,7 +110,11 @@
             _debug_('UnicodeError: %s' % [x for x in text])
 
         _debug_('festival.say %s' % text)
-        self.fest.say(text)
+        if self.output == 'festival':
+         self.fest.say(text)
+        else:
+         os.system('%s "%s" 1>/dev/null 2>&1&' % \
+         (self.output, text))
 
 
     def eventhandler(self, event, menuw=None):
Index: freevo_config.py
===================================================================
--- freevo_config.py    (revision 11144)
+++ freevo_config.py    (working copy)
@@ -929,6 +929,7 @@
 # plugin.activate('speak')
 SPEAK_WELCOME = ''
 SPEAK_SHUTDOWN = ''
+SPEAK_OUTPUT = 'festival'
 
 # ----------------------------------------------------------------------
 # CD Ripping

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Freevo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-users

Reply via email to