diff options
Diffstat (limited to '__main__.py')
-rw-r--r-- | __main__.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/__main__.py b/__main__.py index ab4f59c..7d6f84b 100644 --- a/__main__.py +++ b/__main__.py @@ -3,13 +3,13 @@ import yaml from pathlib import Path -from modules.config import Config +from .modules.config import Config from .modules.config import load_config from .modules.hassil.recognize import recognize from .modules.hassil.util import merge_dict from .modules.hassil.intents import Intents, TextSlotList -from modules.responses.responses import Responses +from .modules.responses.response_manager import ResponseManager from .modules.input_handlers.stdin_input import StdinInput from .modules.input_handlers.pipewire_record import PipeWireRecord @@ -28,14 +28,6 @@ def main(): intents = Intents.from_dict(input_dict) - response_yaml_path = Path(config.responses_dir) - response_yaml_file_paths = response_yaml_path.glob("*.yaml") - for yaml_file_path in response_yaml_file_paths: - with open(yaml_file_path, "r", encoding="utf-8") as yaml_file: - merge_dict(input_dict, yaml.safe_load(yaml_file)) - - responses = Responses.from_dict(input_dict) - processes = [] for file in os.listdir(config.applications_dir): if file == "[": @@ -50,9 +42,9 @@ def main(): } input_handler = PipeWireRecord() if config.input_mode == Config.INPUT_PW else StdinInput() + response_manager = ResponseManager(config) try: - # TODO select input type from config for input_text in input_handler.get_input(): result = recognize(input_text, intents, slot_lists=slot_lists) if result is not None: @@ -61,10 +53,13 @@ def main(): **{e.name: e.value for e in result.entities_list}, } print(result_dict) + + response_manager.respond(result.response, result.intent.name) + handler = getattr(globals()[result_dict["domain"]], result_dict["intent"]) handler(result_dict, config) else: - print("<no match>") + print("<no intent match>") finally: input_handler.cleanup() |