Pārlūkot izejas kodu

now user can override the cache settings in Say neuron

Nicolas Marcq 8 gadi atpakaļ
vecāks
revīzija
5a0b06ea9d
4 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 1 1
      Docs/dev_env_install.md
  2. 14 1
      neurons/Neurone.py
  3. 3 3
      neurons/say/say.py
  4. 1 0
      settings.yml

+ 1 - 1
Docs/dev_env_install.md

@@ -12,7 +12,7 @@ Tested env
 ### Packages installation
 On Ubuntu distribution:
 ```
-sudo apt-get install python-pip python-dev libsmpeg0 libtts-pico-utils sudo apt-get install libsmpeg0 flac dialog
+sudo apt-get install python-pip python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog
 ```
 
 ### Python lib

+ 14 - 1
neurons/Neurone.py

@@ -54,6 +54,12 @@ class Neurone:
             self.tts = tts
             self.tts_args = ConfigurationManager.get_tts_args(self.tts)
 
+        # get if the cache settings is present
+        override_cache = kwargs.get('cache', None)
+        if override_cache is not None:
+            # the user set the "cache var"
+            self.tts_args = self._update_cache_var(override_cache)
+
         # check if it's a single message or multiple one
         if isinstance(message, list):
             # then we pick randomly one message
@@ -116,4 +122,11 @@ class Neurone:
     @staticmethod
     def _get_content_of_file(real_file_template_path):
         with open(real_file_template_path, 'r') as content_file:
-            return content_file.read()
+            return content_file.read()
+
+    def _update_cache_var(self, override_cache):
+        print "args for TTS plugin before update: %s" % str(self.tts_args)
+        self.tts_args["cache"] = override_cache
+
+        print "args for TTS plugin after update: %s" % str(self.tts_args)
+        return self.tts_args

+ 3 - 3
neurons/say/say.py

@@ -6,12 +6,12 @@ class NoMessageException(Exception):
 
 
 class Say(Neurone):
-    def __init__(self, *args , **kwargs):
-        Neurone.__init__(self, *args, **kwargs)
+    def __init__(self, *args, **kwargs):
+        Neurone.__init__(self, **kwargs)
         # get message to spell out loud
         message = kwargs.get('message', None)
         # user must specify a message
         if message is None:
             raise NoMessageException("You must specify a message string or a list of messages as parameter")
         else:
-            self.say(message, kwargs)
+            self.say(message, kwargs)

+ 1 - 0
settings.yml

@@ -41,3 +41,4 @@ text_to_speech:
   - voxygen:
       language: "fr"
       voice: "michel"
+      cache: True