summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-11-24 23:53:13 +0100
committerBotond Hende <nettingman@gmail.com>2024-11-24 23:53:13 +0100
commit965c0e3401a4743c4f5e91e2368fd04b0b24aa02 (patch)
treed9428a6f15a6b480d079f53bbc802efca13eafca /__main__.py
parenta54f9cbed78ce3df4252c209553f4f318bc2b81e (diff)
input_handler can be specified from config
Diffstat (limited to '__main__.py')
-rw-r--r--__main__.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/__main__.py b/__main__.py
index b51e70b..797ec56 100644
--- a/__main__.py
+++ b/__main__.py
@@ -1,15 +1,16 @@
import os
-import sys
import yaml
from pathlib import Path
+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.input_handlers.stdin_input import get_input_stdin
-from .modules.input_handlers.pipewire_record import get_input_pw_record, cleanup
+
+from .modules.input_handlers.stdin_input import StdinInput
+from .modules.input_handlers.pipewire_record import PipeWireRecord
from .modules.intents import *
@@ -40,9 +41,11 @@ def main():
intents = Intents.from_dict(input_dict)
+ input_handler = PipeWireRecord() if config.input_handler == Config.INPUT_PW else StdinInput()
+
try:
# TODO select input type from config
- for input_text in get_input_pw_record():
+ for input_text in input_handler.get_input():
result = recognize(input_text, intents, slot_lists=slot_lists)
if result is not None:
result_dict = {
@@ -55,7 +58,7 @@ def main():
else:
print("<no match>")
finally:
- cleanup()
+ input_handler.cleanup()
if __name__ == '__main__':
main() \ No newline at end of file