ソースを参照

add systemdate test

Nicolas Marcq 8 年 前
コミット
f487ec078b

+ 17 - 0
brain_examples/fr/fr_systemdate.yml

@@ -0,0 +1,17 @@
+- name: "Say local date"
+  neurons:
+    - systemdate:
+        say_template:
+          - "Il est {{ hours }} heures et {{ minutes }} minutes"
+        tts: "pico2wave"
+  signals:
+    - order: "test"
+
+
+- name: "Say local date"
+  neurons:
+    - systemdate:
+        file_template: fr_systemdate_template_example.j2
+        tts: "pico2wave"
+  signals:
+    - order: "test 2"

+ 2 - 1
core/Cache.py

@@ -13,7 +13,8 @@ DEFAULT_VOICE = "default"
 
 class Cache:
 
-    def __init__(self, module_name=DEFAULT_MODULE_NAME, cache_path=DEFAULT_CACHE_PATH, cache_extension=DEFAULT_CACHE_EXTENSION):
+    def __init__(self, module_name=DEFAULT_MODULE_NAME, cache_path=DEFAULT_CACHE_PATH,
+                 cache_extension=DEFAULT_CACHE_EXTENSION):
         self._module_name = module_name
         self._cache_path = cache_path
         self._cache_extension = cache_extension

+ 4 - 2
core/Models/Neurone.py

@@ -47,8 +47,6 @@ class Neurone(object):
             self.tts = SettingLoader().get_default_text_to_speech()
         # get tts args
         self.tts_args = SettingLoader().get_tts_args(self.tts)
-        # capitalise for loading module name
-        self.tts = self.tts.capitalize()
         # load the module
         self.tts_instance = self._get_tts_instance()
 
@@ -56,7 +54,9 @@ class Neurone(object):
         # get the tts if is specified otherwise use default
         tts = kwargs.get('tts', None)
         if tts is not None:
+            # the user want to use another TSS than the default one for this neuron
             self.tts = tts
+            self.tts_instance = self._get_tts_instance()
             self.tts_args = SettingLoader().get_tts_args(self.tts)
 
         # get if the cache settings is present
@@ -108,6 +108,8 @@ class Neurone(object):
         self.tts_instance.say(words=message, **(self.tts_args if self.tts_args is not None else {}))
 
     def _get_tts_instance(self):
+        # capitalise for loading module name
+        self.tts = self.tts.capitalize()
         logging.info("Import TTS module named %s " % self.tts)
         mod = __import__('tts', fromlist=[str(self.tts)])
         try:

+ 1 - 1
neurons/say/say.py

@@ -6,7 +6,7 @@ class NoMessageException(Exception):
 
 
 class Say(Neurone):
-    def __init__(self, *args, **kwargs):
+    def __init__(self, **kwargs):
         Neurone.__init__(self, **kwargs)
         # get message to spell out loud
         message = kwargs.get('message', None)

+ 1 - 1
neurons/systemdate/systemdate.py

@@ -5,7 +5,7 @@ from core.Models.Neurone import Neurone
 
 
 class Systemdate(Neurone):
-    def __init__(self, *args , **kwargs):
+    def __init__(self, **kwargs):
         Neurone.__init__(self, **kwargs)
 
         # get hours and minutes

+ 1 - 1
test.py

@@ -1,6 +1,6 @@
 # coding=utf-8
 from core.OrderAnalyser import OrderAnalyser
 
-oa = OrderAnalyser("sens de la vie", brain_file="brain_examples/fr/say_examples.yml")
+oa = OrderAnalyser("test 2", brain_file="brain_examples/fr/fr_systemdate.yml")
 
 oa.start()

+ 4 - 0
tts/pico2wave/pico2wave.py

@@ -8,6 +8,10 @@ class Pico2wave(TTS):
     PICO2WAVE_LANGUAGES_DEFAULT = PICO2WAVE_LANGUAGES['fr']
 
     def __init__(self, audio_player_type=None):
+        """
+
+        :param audio_player_type: MP3 or WAV
+        """
         TTS.__init__(self, audio_player_type, "wav")
 
     def say(self, words=None, language=PICO2WAVE_LANGUAGES_DEFAULT, cache=False):