예제 #1
0
def init_trainers(ivi_settings: SettingsContainer):
    global _trainer_geo_locations

    # Init GeoLocationsTrainer
    processes_abs_folder_path: str = ivi_settings.get_setting(
        common_keywords_settings.ARG_PROCESSES_FOLDER_PATH)
    geo_locations_identifier_model_folder_path: str = ivi_settings.get_setting(
        locations_keywords_settings.ARG_LOCATION_TAGGER_MODEL_FOLDER_PATH)
    _trainer_geo_locations = GeoLocationsTrainer(
        processes_abs_folder_path, geo_locations_identifier_model_folder_path)
def init_processes(ivi_settings: SettingsContainer,
                   ivi_lockers: LockersContainer):
    global _processes

    processes_namespaces_folder_path = ivi_settings.get_setting(
        consts_processes.SETTINGS_PROCESSES_NAMESPACE_FOLDER_PATH)
    _processes = processes_namespace.get_loaded_namespaces(
        processes_namespaces_folder_path)

    args = {
        keywords_process.ARG_SETTINGS_CONTAINER: ivi_settings,
        keywords_process.ARG_LOCKERS_CONTAINER: ivi_lockers,
        keywords_process.ARG_INS_MECHANISMS_CARRIERS: {
            keywords_process.ARG_INS_MECHANISMS_MECHANISM_DEFAULT:
            InputMechanismCarrier(input_handler.default_input_mechanism),
            **utils.mechanisms.get_carries_by_mechanisms(
                InputMechanismCarrier.CARRIER_TYPE,
                input_handler.ivi_get_ins_mechanisms())
        },
        keywords_process.ARG_OUTS_MECHANISMS_CARRIERS: {
            keywords_process.ARG_OUTS_MECHANISMS_MECHANISM_DEFAULT:
            OutputMechanismCarrier(output_handler.default_output_mechanism),
            **utils.mechanisms.get_carries_by_mechanisms(
                OutputMechanismCarrier.CARRIER_TYPE,
                output_handler.ivi_get_outs_mechanisms())
        }
    }

    for process in _processes:
        process.start_process(args)
    def __init__(self, ivi_settings: SettingsContainer,
                 ivi_lockers: LockersContainer):
        self._settings_container = ivi_settings
        self._lockers_container = ivi_lockers

        prediction_model_filepath = ivi_settings.get_setting(
            tasks_consts.SETTINGS_MODEL_FILEPATH)
        prediction_threshold = float(
            ivi_settings.get_setting(
                tasks_consts.SETTINGS_PREDICTION_THRESHOLD))

        self._predictor = Predictor(model_filepath=prediction_model_filepath,
                                    prediction_threshold=prediction_threshold)

        self._INIT_SUCCESS = False
        tasks_namespaces_folderpath = ivi_settings.get_setting(
            tasks_consts.SETTINGS_TASKS_NAMESPACES_FOLDERPATH)
        # This would automatically validate the namespaces inside.
        self._class_namespaces = self._predictor.get_loaded_namespaces(
            tasks_namespaces_folderpath)
        self._INIT_SUCCESS = True
예제 #4
0
import time
from emucorebrain.data.carriers.ins_mechanism import InputMechanismCarrier
from emucorebrain.data.carriers.outs_mechanism import OutputMechanismCarrier
from emucorebrain.data.carriers.string import StringCarrier
from emucorebrain.data.containers.settings import SettingsContainer
from emucorebrain.io.mechanisms.ins_mechanism import Grabber, GrabberController
from FindMapsExecutor.FindMapsExecutor import FindMapsExecutor
from tests.io.ins_mechanisms import TerminalInputMechanism
from tests.io.outs_mechanisms import TerminalOutputMechanism
import emucorebrain.keywords.task_executor as keywords_task_executor

find_maps_executor: FindMapsExecutor = FindMapsExecutor()
ins_terminal_mechanism: TerminalInputMechanism = TerminalInputMechanism()
outs_terminal_mechanism: TerminalOutputMechanism = TerminalOutputMechanism()
ivi_settings = SettingsContainer("../../../EmulationCore/settings.json")

outs_terminal_mechanism.write_data("Please type in the sentence with location. Eg: \"Find me the city of New York\"\nEnter: \"@end_kill\" to terminate testing.")
def process_sentence(sentence, *disc_args):
    ins_terminal_mechanism.get_grabber_controller().pop_out_grabber(GrabberController.MAX_PRIORITY_INDEX)
    args = {
        keywords_task_executor.ARG_SPEECH_TEXT_DATA: StringCarrier(sentence),
        keywords_task_executor.ARG_SETTINGS_CONTAINER: ivi_settings,
        keywords_task_executor.ARG_INS_MECHANISMS_CARRIERS: {
            keywords_task_executor.ARG_INS_MECHANISMS_MECHANISM_DEFAULT: InputMechanismCarrier(ins_terminal_mechanism),
        },
        keywords_task_executor.ARG_OUTS_MECHANISMS_CARRIERS: {
            keywords_task_executor.ARG_OUTS_MECHANISMS_MECHANISM_DEFAULT: OutputMechanismCarrier(outs_terminal_mechanism),
        }
    }
    find_maps_executor.run(args)
ins_terminal_mechanism.get_grabber_controller().pop_in_grabber(Grabber(on_exec=process_sentence), GrabberController.MAX_PRIORITY_INDEX)
예제 #5
0
import base.input_handler as input_handler
import base.output_handler as output_handler
import base.process_handler as process_handler
from emucorebrain.data.containers.settings import SettingsContainer
from emucorebrain.data.containers.lockers import LockersContainer
import base.consts.consts as emucore_consts
from threading import Thread
import time
# Temporary content which is to be changed in the coming days
from emucorebrain.io.mechanisms.ins_mechanism import GrabberController
from ins.microphone import InputMicrophone

ivi_shutdown = False

# Initializes the Settings Container.
ivi_settings = SettingsContainer(emucore_consts.SETTINGS_FILEPATH)
# Initializes the Lockers Container
ivi_lockers = LockersContainer()

# Initializes all the outputs(mechanisms).
output_handler.ivi_init_outputs()
# Initializes all the inputs(mechanisms).
input_handler.ivi_init_inputs(ivi_settings, ivi_lockers)
# Initializes and starts all the processes.
process_handler.init_processes(ivi_settings, ivi_lockers)
process_handler.start_processes()
# Outputs the status via default output mechanism.
output_handler.output_via_mechanism(
    output_handler.default_output_mechanism,
    "Initialization successful. Waiting for Commands.",
    wait_until_completed=False,