Jelajahi Sumber

Merge branch 'dev' into Doc

monf 8 tahun lalu
induk
melakukan
1509741a3a
6 mengubah file dengan 87 tambahan dan 8 penghapusan
  1. 1 0
      Docs/neuron_list.md
  2. 46 2
      Docs/neurons.md
  3. 1 1
      Docs/stt.md
  4. 1 1
      README.md
  5. 37 3
      core/ShellGui.py
  6. 1 1
      kalliope.py

+ 1 - 0
Docs/neuron_list.md

@@ -1,5 +1,6 @@
 # List of available neuron
 
+A neuron is a module you can use in your synapses. See the [complete neuron documentation](neurons.md) for more information.
 
 | Name                                                | Description                                                                             |
 |-----------------------------------------------------|-----------------------------------------------------------------------------------------|

+ 46 - 2
Docs/neurons.md

@@ -3,6 +3,7 @@
 A neuron is a plugin that you can use in a synapse to perform action. 
 Neurons are executed one by one when the input action is triggered.
 
+## Usage
 Neurons are declared in the `neurons` section of a synapse in your brain file.
 The `neurons` section is a list (because it starts with a "-") which contains neuron module name
 ```
@@ -19,9 +20,52 @@ neurons:
         parameter1: "value1"
         parameter2: "value2"
 ```
-> **note:** parameters are indented with one tabulation bellow the neuron's name.
+> **note:** parameters are indented with two spaces bellow the neuron's name following the YAML syntax.
 
 To know which parameter are required, check of documentation of the neuron.
-
 Full list of [available neuron here](neuron_list.md)
 
+## Overridable parameters
+
+For each neuron, you can override some parameters to use a specific configuration of TTS instead of the default one 
+set in [settings.yml](settings.yml) file.
+
+### Cache
+
+You can choose to override the default cache configuration. By default Kalliope use a cache to save a generated audio from a TTS engine.
+This cache is usefull when you know that the text to speech will not change like in the following example
+```
+- say:
+    message:
+      - "Hello, sir"
+```
+
+In some case, and more specially when the neuron is based on a template, the generated audio will change at each new call of the neuron and so the usage 
+of a cache is not necessary. 
+The best example is when you use the `systemdate` neuron. As the time change every minute, the generated audio will change too.
+Saving a cache of the generated audio is useless in this case. It where the usage of a cache override become usefull.
+```
+- systemdate:
+    say_template:
+      - "It's {{ hours }} hour and {{ minutes }} minute"
+    cache: False
+```
+
+### tts
+
+You can override the default tts in each neurons. Just add the tts parameter to the neuron like in the example bellow
+```
+neurons:
+  - say:
+    message:
+      - "Hello, sir"
+  - say:
+    message:
+      - "My name is Kalliope"
+    tts: "voxygen"
+```
+
+Here, the first neuron will use the default tts as set in the settings.yml file. The second neuron will use the tts "voxygen".
+
+>**Note:** The TTS must has been configured with its required parameters in the settings.yml file. See [TTS documentation](tts.md).
+

+ 1 - 1
Docs/stt.md

@@ -1,7 +1,7 @@
 # Speech To Text (STT)
 # TODO update to place each STT doc the its proper directory
 This chapter describes how STT are working.
-This configuration must apply in the settings.yml.
+This configuration must apply in the [settings.yml](settings.md) file.
 
 The syntax used is YAML.
 

+ 1 - 1
README.md

@@ -33,7 +33,7 @@ Kalliope is easy-peasy to use, see the hello world
 
 A neuron is a plugin that can be used from your **brain.yml**. 
 
-- See the list of [available neurons](Docs/neurons.md).
+- See the list of [available neurons](Docs/neuron_list.md).
 - See how to [create your own neuron](Docs/contributing.md).
 
 

+ 37 - 3
core/ShellGui.py

@@ -9,6 +9,8 @@ from dialog import Dialog
 import locale
 
 from core import OrderListener
+from core.ConfigurationManager.BrainLoader import BrainLoader
+from core.SynapseLauncher import SynapseLauncher
 from core.Utils import Utils
 from core.ConfigurationManager import SettingLoader
 from neurons import Say
@@ -26,7 +28,9 @@ signal.signal(signal.SIGINT, signal_handler)
 
 
 class ShellGui:
-    def __init__(self):
+    def __init__(self, brain_file=None):
+        # override brain
+        self.brain_file = brain_file
         # get settings
         self.settings = SettingLoader.get_settings()
         locale.setlocale(locale.LC_ALL, '')
@@ -46,13 +50,16 @@ class ShellGui:
 
         code, tag = self.d.menu("Test your Kalliope settings from this menu",
                                 choices=[("TTS", "Text to Speech"),
-                                         ("STT", "Speech to text")])
+                                         ("STT", "Speech to text"),
+                                         ("Synapses", "Run a synapse")])
 
         if code == self.d.OK:
             if tag == "STT":
                 self.show_stt_test_menu()
             if tag == "TTS":
                 self.show_tts_test_menu()
+            if tag == "Synapses":
+                self.show_synapses_test_menu()
 
     def show_stt_test_menu(self):
         # we get STT from settings
@@ -105,7 +112,8 @@ class ShellGui:
                 # then go back to this menu with the same sentence
                 self.show_tts_test_menu(sentence_to_test=sentence_to_test)
 
-    def _run_tts_test(self, tts_name, sentence_to_test):
+    @staticmethod
+    def _run_tts_test(tts_name, sentence_to_test):
         """
         Call the TTS
         :param tts_name: Name of the TTS module to launch
@@ -141,3 +149,29 @@ class ShellGui:
 
         if code == self.d.OK:
             self.show_stt_test_menu()
+
+    def show_synapses_test_menu(self):
+        """
+        Show a list of available synapse in the brain to run it directly
+        :return:
+        """
+        # get the list of synapse from the brain
+        brain = BrainLoader.get_brain(file_path=self.brain_file)
+
+        # create a tuple for the list menu
+        choices = list()
+        x = 0
+        for el in brain.synapses:
+            tup = (str(el.name), str(x))
+            choices.append(tup)
+            x += 1
+
+        code, tag = self.d.menu("Select a synapse to run",
+                                choices=choices)
+
+        if code == self.d.CANCEL:
+            self.show_main_menu()
+        if code == self.d.OK:
+            logger.debug("Run synapse from GUI: %s" % tag)
+            SynapseLauncher.start_synapse(tag, brain_file=self.brain_file)
+            self.show_synapses_test_menu()

+ 1 - 1
kalliope.py

@@ -78,7 +78,7 @@ def main():
             MainController(brain_file=brain_file)
 
     if args.action == "gui":
-        ShellGui()
+        ShellGui(args.brain_file)
 
 
 def configure_logging(debug=None):