Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LiteRT and more flexibility #216

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion openwakeword/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ 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'],
'litert': ['ai-edge-litert>=1.0.1,<2'],
'test': [
'pytest>=7.2.0,<8',
'pytest-cov>=2.10.1,<3',
Expand Down