def load_stt_plugin(self): if self.stt is None: self.stt_module_name = self.settings.default_stt_name for stt_object in self.settings.stts: if stt_object.name == self.stt_module_name: stt_object.parameters["callback"] = self.callback Utils.get_dynamic_class_instantiation('stt', stt_object.name.capitalize(), parameters=stt_object.parameters)
def start_neurone(cls, neuron): """ Start a neuron plugin :param neuron: neuron object :type neuron: Neurone :return: """ logger.debug("Run plugin \"%s\" with parameters %s" % (neuron.name, neuron.parameters)) return Utils.get_dynamic_class_instantiation("neurons", neuron.name.capitalize(), neuron.parameters)
def say(self, message): """ USe TTS to speak out loud the Message. A message can be a string, a list or a dict If it's a string, simply use the TTS with the message If it's a list, we select randomly a string in the list and give it to the TTS If it's a dict, we use the template given in parameter to create a string that we give to the TTS :param message: Can be a String or a dict or a list .. raises:: TTSModuleNotFound """ logger.debug("NeuronModule Say() called with message: %s" % message) tts_message = None if isinstance(message, str) or isinstance(message, unicode): logger.debug("message is string") tts_message = message if isinstance(message, list): logger.debug("message is list") tts_message = random.choice(message) if isinstance(message, dict): logger.debug("message is dict") tts_message = self._get_message_from_dict(message) if tts_message is not None: logger.debug("tts_message to say: %s" % tts_message) # create a tts object from the tts the user want to user tts_object = next( (x for x in self.settings.ttss if x.name == self.tts), None) if tts_object is None: raise TTSModuleNotFound( "The tts module name %s does not exist in settings file" % self.tts) # change the cache settings with the one precised for the current neuron if self.override_cache is not None: tts_object.parameters = self._update_cache_var( self.override_cache, tts_object.parameters) logger.debug("NeuroneModule: TTS args: %s" % tts_object) # get the instance of the TTS module tts_module_instance = Utils.get_dynamic_class_instantiation( "tts", tts_object.name.capitalize(), tts_object.parameters) # generate the audio file and play it tts_module_instance.say(tts_message)
def _get_tts_instance(tts_name): return Utils.get_dynamic_class_instantiation("tts", tts_name.capitalize())