diff options
author | Botond Hende <nettingman@gmail.com> | 2024-11-20 13:46:44 +0100 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-11-20 13:46:44 +0100 |
commit | a54f9cbed78ce3df4252c209553f4f318bc2b81e (patch) | |
tree | 138fcc62d161fe07d47d35ecd99043f2ffc340bd /__main__.py | |
parent | a7448c94421b6ac874d33a5e0b4f8731931dad3e (diff) |
cleanup pipo when exiting
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 |