|
@@ -2,15 +2,15 @@ import logging
|
|
|
import os
|
|
|
import random
|
|
|
|
|
|
+from flask import Flask
|
|
|
+
|
|
|
from core import Utils
|
|
|
from core.ConfigurationManager import SettingLoader
|
|
|
-from core.ConfigurationManager.BrainLoader import BrainLoader
|
|
|
from core.OrderAnalyser import OrderAnalyser
|
|
|
from core.OrderListener import OrderListener
|
|
|
from core.Players import Mplayer
|
|
|
-from core.TriggerLauncher import TriggerLauncher
|
|
|
-from flask import Flask
|
|
|
from core.RestAPI.FlaskAPI import FlaskAPI
|
|
|
+from core.TriggerLauncher import TriggerLauncher
|
|
|
from neurons import Say
|
|
|
|
|
|
logging.basicConfig()
|
|
@@ -18,11 +18,8 @@ logger = logging.getLogger("kalliope")
|
|
|
|
|
|
|
|
|
class MainController:
|
|
|
-
|
|
|
"""
|
|
|
-
|
|
|
- This Class is the global controller of the application.
|
|
|
-
|
|
|
+ This Class is the global controller of the application.
|
|
|
"""
|
|
|
def __init__(self, brain=None):
|
|
|
self.brain = brain
|
|
@@ -45,10 +42,10 @@ class MainController:
|
|
|
|
|
|
def callback(self):
|
|
|
"""
|
|
|
- we have detected the hotword, we can now pause the Trigger for a while
|
|
|
- The user can speak out loud his order during this time.
|
|
|
+ we have detected the hotword, we can now pause the Trigger for a while
|
|
|
+ The user can speak out loud his order during this time.
|
|
|
"""
|
|
|
- # pause the snowboy process
|
|
|
+ # pause the trigger process
|
|
|
self.trigger_instance.pause()
|
|
|
# start listening for an order
|
|
|
self.order_listener.start()
|
|
@@ -61,8 +58,9 @@ class MainController:
|
|
|
|
|
|
def analyse_order(self, order):
|
|
|
"""
|
|
|
- Receive an order, try to retreive it in the brain.yml to launch to attached plugins
|
|
|
- :param order: the sentence received
|
|
|
+ Receive an order, try to retreive it in the brain.yml to launch to attached plugins
|
|
|
+ :param order: the sentence received
|
|
|
+ :type order: str
|
|
|
"""
|
|
|
order_analyser = OrderAnalyser(order, main_controller=self, brain=self.brain)
|
|
|
order_analyser.start()
|
|
@@ -76,8 +74,8 @@ class MainController:
|
|
|
|
|
|
def _get_default_trigger(self):
|
|
|
"""
|
|
|
- Return an instance of the default trigger
|
|
|
- :return: Trigger
|
|
|
+ Return an instance of the default trigger
|
|
|
+ :return: Trigger
|
|
|
"""
|
|
|
for trigger in self.settings.triggers:
|
|
|
if trigger.name == self.settings.default_trigger_name:
|
|
@@ -86,11 +84,11 @@ class MainController:
|
|
|
@staticmethod
|
|
|
def _get_random_sound(random_wake_up_sounds):
|
|
|
"""
|
|
|
- Return a path of a sound to play
|
|
|
- If the path is absolute, test if file exist
|
|
|
- If the path is relative, we check if the file exist in the sound folder
|
|
|
- :param random_wake_up_sounds: List of wake_up sounds
|
|
|
- :return: path of a sound to play
|
|
|
+ Return a path of a sound to play
|
|
|
+ If the path is absolute, test if file exist
|
|
|
+ If the path is relative, we check if the file exist in the sound folder
|
|
|
+ :param random_wake_up_sounds: List of wake_up sounds
|
|
|
+ :return: path of a sound to play
|
|
|
"""
|
|
|
# take first randomly a path
|
|
|
random_path = random.choice(random_wake_up_sounds)
|