Exemple #1
0
class TtsManager(XplPlugin):
    """ Manage Tts
    """

    def __init__(self):
        """ Init manager
        """
        XplPlugin.__init__(self, name = 'tts')

        # Configuration

        self._config = Query(self.myxpl, self.log)
        software = self._config.query('tts', 'software')

        self.log.debug("Init info for tts created")
        ### Create tts objects
        self.my_tts = Tts(self.log, software)
	self.log.debug("Create object for tts created")
        # Create listener
        Listener(self.tts_cb, self.myxpl, {'schema': 'tts.basic','xpltype': 'xpl-cmnd'})
        self.log.debug("Listener for tts created")

        self.enable_hbeat()


    def tts_cb(self, message):
        """ Call tts lib
            @param message : xPL message detected by listener
        """
        # body contains the message
	self.log.debug("Function call back : entry")
        if 'speech' in message.data:
            speech = message.data['speech']
        else:
            self._log.warning("Xpl message : missing 'speech' attribute")
            return

        try:
	    self.log.debug("function call back : before send")
            self.my_tts.send(speech)
	    self.log.debug("function call back : after send")
        except:
	       self.log.error("Error while sending tts : %s" % traceback.format_exc())
              
               return
Exemple #2
0
    def __init__(self):
        """ Init manager
        """
        XplPlugin.__init__(self, name = 'tts')

        # Configuration

        self._config = Query(self.myxpl, self.log)
        software = self._config.query('tts', 'software')

        self.log.debug("Init info for tts created")
        ### Create tts objects
        self.my_tts = Tts(self.log, software)
	self.log.debug("Create object for tts created")
        # Create listener
        Listener(self.tts_cb, self.myxpl, {'schema': 'tts.basic','xpltype': 'xpl-cmnd'})
        self.log.debug("Listener for tts created")

        self.enable_hbeat()