From c39f8edc7376777d5c6fa387c16642cae02a438e Mon Sep 17 00:00:00 2001 From: stkr22 Date: Sat, 16 Nov 2024 14:38:11 +0100 Subject: [PATCH 1/2] removing explicit onnx/tensorflow lite dependency in favor of more flexibility; --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index df0a666..c0795b5 100644 --- a/setup.py +++ b/setup.py @@ -26,16 +26,16 @@ def build_additional_requires(): setuptools.setup( name="openwakeword", - version="0.6.0", + version="0.6.1", install_requires=[ - 'onnxruntime>=1.10.0,<2', - 'tflite-runtime>=2.8.0,<3; platform_system == "Linux"', 'tqdm>=4.0,<5.0', 'scipy>=1.3,<2', 'scikit-learn>=1,<2', 'requests>=2.0,<3', ], extras_require={ + 'onnx': ['onnxruntime>=1.10.0,<2'], + 'tflite': ['tflite-runtime>=2.8.0,<3; platform_system == "Linux"'], 'test': [ 'pytest>=7.2.0,<8', 'pytest-cov>=2.10.1,<3', From af84a8166b52663aa375462c919fb541da016471 Mon Sep 17 00:00:00 2001 From: stkr22 Date: Sat, 16 Nov 2024 14:39:50 +0100 Subject: [PATCH 2/2] adding litert as an alternative to tflite; --- openwakeword/model.py | 10 +++++++++- setup.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/openwakeword/model.py b/openwakeword/model.py index 6029963..787e30a 100755 --- a/openwakeword/model.py +++ b/openwakeword/model.py @@ -111,7 +111,15 @@ def __init__( # Do imports for inference framework if inference_framework == "tflite": try: - import tflite_runtime.interpreter as tflite + try: + # Attempt to import the newer LiteRT runtime + import ai_edge_litert.interpreter as tflite + except ImportError: + try: + # Fallback to the original tflite_runtime if LiteRT is unavailable + import tflite_runtime.interpreter as tflite + except ImportError: + raise ImportError("Neither LiteRT nor TensorFlow Lite runtime found. Please install `ai_edge_litert` or `tflite_runtime`.") def tflite_predict(tflite_interpreter, input_index, output_index, x): tflite_interpreter.set_tensor(input_index, x) diff --git a/setup.py b/setup.py index c0795b5..047b9e4 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,8 @@ def build_additional_requires(): ], extras_require={ 'onnx': ['onnxruntime>=1.10.0,<2'], - 'tflite': ['tflite-runtime>=2.8.0,<3; platform_system == "Linux"'], + 'tflite': ['tflite-runtime>=2.8.0,<3'], + 'litert': ['ai-edge-litert>=1.0.1,<2'], 'test': [ 'pytest>=7.2.0,<8', 'pytest-cov>=2.10.1,<3',