فهرست منبع

we can now override the default brain.yml by setting our own filename on orderlistener

Nicolas Marcq 10 سال پیش
والد
کامیت
eef7638410
6فایلهای تغییر یافته به همراه23 افزوده شده و 20 حذف شده
  1. 1 0
      brain.yml
  2. 10 8
      core/OrderAnalyser.py
  3. 4 2
      neurons/Neurone.py
  4. 1 1
      settings.yml
  5. 4 4
      test.py
  6. 3 5
      test.yml

+ 1 - 0
brain.yml

@@ -45,6 +45,7 @@
       - systemdate:
           file_template: fr_systemdate_template_example.j2
           tts: "voxygen"
+          cache: False
     when:
       - order: "test heure"
 

+ 10 - 8
core/OrderAnalyser.py

@@ -1,27 +1,29 @@
 import re
 
 from core import ConfigurationManager
+from core.ConfigurationManager.BrainLoader import BrainLoader
 from core.NeuroneLauncher import NeuroneLauncher
+import logging
 
 
 class OrderAnalyser:
-    def __init__(self, order, main_controller=None):
+    def __init__(self, order, main_controller=None, brain_file=None):
         """
-        Class used to load
+        Class used to load brain and run neuron attached to the received order
         :param order: spelt order
         :param main_controller
+        :param brain_file: To override the default brain.yml file
         """
         self.main_controller = main_controller
         self.order = order
-        self.brain = ConfigurationManager.get_brain()
-        print "Receiver order: %s" % self.order
+        if brain_file is None:
+            self.brain = ConfigurationManager.get_brain()
+        else:
+            self.brain = BrainLoader(brain_file).get_config()
+        logging.info("Receiver order: %s" % self.order)
 
     def start(self):
-        print self.brain
-
         for el in self.brain:
-            # print el
-            # print el["when"]
             whens = el["when"]
             for when in whens:
                 brain_order = when["order"]

+ 4 - 2
neurons/Neurone.py

@@ -29,9 +29,11 @@ class TTSNotInstantiable(Exception):
 
 class Neurone:
     def __init__(self, **kwargs):
-        # get the name of the plugin
+        # get the name of the plugin who load Neurone mother class
         # print self.__class__.__name__
-        # load the tts from settings
+
+        print "Neurone class called with parameters: %s" % kwargs
+
         # get the tts if is specified otherwise use default
         tts = kwargs.get('tts', None)
         if tts is not None:

+ 1 - 1
settings.yml

@@ -11,7 +11,7 @@ trigger:
 # This is the STT that will be used by default
 default_speech_to_text: "google"
 # This is the default TTS that will be used by JARVIS to talk.
-default_text_to_speech: "pico2wave"
+default_text_to_speech: "voxygen"
 
 # When jarvis detect the hotword/trigger, he will select randomly a phrase in the following list
 # to notify the user that he's listening for orders

+ 4 - 4
test.py

@@ -10,9 +10,9 @@ import logging
 from core import ShellGui
 
 
-# oa = OrderAnalyser("test heure")
-#
-# oa.start()
+oa = OrderAnalyser("dis bonjour", brain_file="test.yml")
+
+oa.start()
+
 
 
-Say(message="bonjour")

+ 3 - 5
test.yml

@@ -1,11 +1,9 @@
 ---
   - name: "Say hello"
     neurons:
-      - command: "/home/nico/tmp/test.sh"
-      - systemdate
-      - say:
-          message: "Commande terminée"
-
+      - systemdate:
+          file_template: fr_systemdate_template_example.j2
+          cache: False
     when:
       - order: "dis bonjour"