mirror of
https://github.com/dscripka/openWakeWord.git
synced 2026-08-27 18:17:20 -04:00
more explicit tensorflow checks
This commit is contained in:
parent
99cd87e889
commit
172e25bfa2
2 changed files with 8 additions and 5 deletions
|
|
@ -119,15 +119,16 @@ class Model():
|
|||
return tflite_interpreter.get_tensor(output_index)[None, ]
|
||||
|
||||
except ImportError:
|
||||
try:
|
||||
from importlib.util import find_spec
|
||||
if find_spec("tensorflow") is not None and find_spec("tflite_runtime") is None:
|
||||
logging.warning("Tried to import the tflite runtime, but it was not found. Using tensorflow instead.")
|
||||
from tensorflow.lite.python import interpreter as tflite
|
||||
|
||||
def tflite_predict(tflite_interpreter, input_index, output_index, x):
|
||||
tflite_interpreter.set_tensor(input_index, x)
|
||||
tflite_interpreter.invoke()
|
||||
return tflite_interpreter.get_tensor(output_index)[None, ]
|
||||
|
||||
except ImportError:
|
||||
else:
|
||||
logging.warning("Tried to import the tflite runtime, but it was not found. "
|
||||
"Trying to switching to onnxruntime instead, if appropriate models are available.")
|
||||
if wakeword_models != [] and all(['.onnx' in i for i in wakeword_models]):
|
||||
|
|
|
|||
|
|
@ -96,9 +96,11 @@ class AudioFeatures():
|
|||
try:
|
||||
import tflite_runtime.interpreter as tflite
|
||||
except ImportError:
|
||||
try:
|
||||
from importlib.util import find_spec
|
||||
if find_spec("tensorflow") is not None and find_spec("tflite_runtime") is None:
|
||||
logging.warning("Tried to import the tflite runtime, but it was not found. Using tensorflow instead.")
|
||||
from tensorflow.lite.python import interpreter as tflite
|
||||
except ImportError:
|
||||
else:
|
||||
raise ValueError("Tried to import the TFLite runtime, but it was not found."
|
||||
"Neither was the TensorFlow interpreter."
|
||||
"Please install TFLite runtime using `pip install tflite-runtime`")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue