diff options
Diffstat (limited to '__main__.py')
-rw-r--r-- | __main__.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/__main__.py b/__main__.py index 4aa3117..b51e70b 100644 --- a/__main__.py +++ b/__main__.py @@ -3,12 +3,13 @@ import sys import yaml from pathlib import Path + 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.input_handlers.stdin_input import get_input_stdin -from .modules.input_handlers.pipewire_record import get_input_pw_record +from .modules.input_handlers.pipewire_record import get_input_pw_record, cleanup from .modules.intents import * @@ -39,18 +40,22 @@ def main(): intents = Intents.from_dict(input_dict) - for input_text in get_input_pw_record(): - result = recognize(input_text, intents, slot_lists=slot_lists) - if result is not None: - result_dict = { - "intent": result.intent.name, - **{e.name: e.value for e in result.entities_list}, - } - print(result_dict) - handler = getattr(globals()[result_dict["domain"]], result_dict["intent"]) - handler(result_dict, config) - else: - print("<no match>") + try: + # TODO select input type from config + for input_text in get_input_pw_record(): + result = recognize(input_text, intents, slot_lists=slot_lists) + if result is not None: + result_dict = { + "intent": result.intent.name, + **{e.name: e.value for e in result.entities_list}, + } + print(result_dict) + handler = getattr(globals()[result_dict["domain"]], result_dict["intent"]) + handler(result_dict, config) + else: + print("<no match>") + finally: + cleanup() if __name__ == '__main__': main()
\ No newline at end of file |