Example #1
0
    def __init__(self, **kwargs):

        # set parameter from what we receive from the settings
        self.cache = kwargs.get('cache', False)
        self.language = kwargs.get('language', None)
        self.voice = kwargs.get('voice', "default")
        # the name of the TSS is the name of the Tss module that have instantiated TTSModule
        self.tts_caller_name = self.__class__.__name__

        # we don't know yet the words that will be converted to an audio and so we don't have the audio path yet too
        self.words = None
        self.file_path = None
        self.base_cache_path = None

        # load settings
        self.settings = SettingLoader.get_settings()

        # create the path in the tmp folder
        base_path = os.path.join(self.settings.cache_path,
                                 self.tts_caller_name, self.language,
                                 self.voice)
        FileManager.create_directory(base_path)

        logger.debug(
            "Class TTSModule called from module %s, cache: %s, language: %s, voice: %s"
            % (self.tts_caller_name, self.cache, self.language, self.voice))
Example #2
0
 def decorated(*args, **kwargs):
     settings = SettingLoader.get_settings()
     if settings.rest_api.password_protected:
         auth = request.authorization
         if not auth or not check_auth(auth.username, auth.password):
             return authenticate()
     return f(*args, **kwargs)
Example #3
0
    def __init__(self, **kwargs):
        """
        Class used by neuron for talking
        :param kwargs: Same parameter as the Child. Can contain info about the tts to use instead of the
        default one
        """
        # get the child who called the class
        child_name = self.__class__.__name__
        logger.debug("NeuronModule called from class %s with parameters: %s" %
                     (child_name, str(kwargs)))

        self.settings = SettingLoader.get_settings()
        self.brain = BrainLoader.get_brain()

        # check if the user has overrider the TTS
        tts = kwargs.get('tts', None)
        if tts is None:
            # No tts provided,  we load the default one
            self.tts = self.settings.default_tts_name
        else:
            self.tts = tts

        # get if the cache settings is present
        self.override_cache = kwargs.get('cache', None)

        # get templates if provided
        # Check if there is a template associate to the output message
        self.say_template = kwargs.get('say_template', None)
        # check if there is a template file associate to the output message
        self.file_template = kwargs.get('file_template', None)
Example #4
0
    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, '')

        self.d = Dialog(dialog="dialog")

        self.d.set_background_title("Kalliope shell UI")

        self.show_main_menu()
Example #5
0
 def __init__(self, callback=None, stt=None):
     """
     This class is called after we catch the hotword that have woke up Kalliope.
     We now wait for an order spoken out loud by the user, translate the order into a text and run the action
      attached to this order from settings
     :param callback: callback function to call
     :param stt: Speech to text plugin name to load. If not provided,
     we will load the default one set in settings
     """
     # this is a trick to ignore ALSA output error
     # see http://stackoverflow.com/questions/7088672/pyaudio-working-but-spits-out-error-messages-each-time
     super(OrderListener, self).__init__()
     self.stt = stt
     self._ignore_stderr()
     self.stt_module_name = stt
     self.callback = callback
     self.settings = SettingLoader.get_settings()
Example #6
0
    def __init__(self, brain_file=None):
        self.brain_file = brain_file
        # get global configuration
        self.settings = SettingLoader.get_settings()

        # run the api if the user want it
        if self.settings.rest_api.active:
            Utils.print_info("Starting REST API Listening port: %s" % self.settings.rest_api.port)
            app = Flask(__name__)
            flask_api = FlaskAPI(app, port=self.settings.rest_api.port, brain_file=brain_file)
            flask_api.start()

        # create an order listener object. This last will the trigger callback before starting
        self.order_listener = OrderListener(self.analyse_order)
        # Wait that the kalliope trigger is pronounced by the user
        self.trigger_instance = self._get_default_trigger()
        self.trigger_instance.start()
        Utils.print_info("Waiting for trigger detection")
Example #7
0
    def __init__(self, brain=None):
        """
        Load a GUI in a shell console for testing TTS, STT and brain configuration
        :param brain: The Brain object provided by the brain.yml
        :type brain: Brain

        .. seealso:: Brain
        """
        # override brain
        self.brain = brain

        # get settings
        self.settings = SettingLoader.get_settings()
        locale.setlocale(locale.LC_ALL, '')

        self.d = Dialog(dialog="dialog")

        self.d.set_background_title("Kalliope shell UI")

        self.show_main_menu()
Example #8
0
def check_auth(username, password):
    """This function is called to check if a username /
    password combination is valid.
    """
    settings = SettingLoader.get_settings()
    return username == settings.rest_api.login and password == settings.rest_api.password
Example #9
0
# coding: utf8
import logging
import re
from collections import Counter

from flask import Flask
from core.RestAPI.FlaskAPI import FlaskAPI
from core import OrderAnalyser
from core.ConfigurationManager import SettingLoader
from core.ConfigurationManager import YAMLLoader
from core.ConfigurationManager.BrainLoader import BrainLoader

from neurons import Systemdate
from neurons.tasker_autoremote.tasker_autoremote import Tasker_autoremote

logging.basicConfig()
logger = logging.getLogger("kalliope")
logger.setLevel(logging.DEBUG)

# order = "quelle heure est-il"
# oa = OrderAnalyser(order=order)
# oa.start()

SettingLoader.get_settings()

# app = Flask(__name__)
# flask_api = FlaskAPI(app)
# flask_api.start()