Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build_and_publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.10"
- name: Install pypa/build
run: >-
python -m
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +28,6 @@ jobs:
sudo apt-get install libspeexdsp-dev
python -m pip install --upgrade pip
pip install -e .[test]
pip install https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp38-cp38-linux_x86_64.whl
- name: Test with pytest
run: |
pytest
Expand All @@ -37,7 +36,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,18 @@ dmypy.json

# Pyre type checker
.pyre/

# Most notebooks
notebooks/
!notebooks/automatic_model_training.ipynb
!notebooks/converting_google_speech_embedding_model.ipynb
!notebooks/performance_metrics.ipynb
!notebooks/training_models.ipynb
!training_tutorial_data

# Most example files
examples/
!examples/audio/activation.wav

# archive files
archive/
2 changes: 1 addition & 1 deletion openwakeword/custom_verifier_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_reference_clip_features(
# Get predictions
for _ in range(N):
# Load clip
if type(reference_clip) == str:
if isinstance(reference_clip, str):
sr, dat = scipy.io.wavfile.read(reference_clip)
else:
dat = reference_clip
Expand Down
4 changes: 2 additions & 2 deletions openwakeword/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ def __init__(self,
self.n_per_class = {}
for lbl, shape in self.shapes.items():
dummy_data = np.random.random((10, self.shapes[lbl][1], self.shapes[lbl][2]))
if self.data_transform_funcs.get(lbl, None):
scale_factor = self.data_transform_funcs.get(lbl, None)(dummy_data).shape[0]/10
if (transform_func := self.data_transform_funcs.get(lbl, None)):
scale_factor = transform_func(dummy_data).shape[0]/10

ratio = self.shapes[lbl][0]/sum([i[0] for i in self.shapes.values()])
self.n_per_class[lbl] = max(1, int(int(batch_size*ratio)/scale_factor))
Expand Down
6 changes: 3 additions & 3 deletions openwakeword/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(
# Do imports for inference framework
if inference_framework == "tflite":
try:
import tflite_runtime.interpreter as tflite
import ai_edge_litert.interpreter as tflite

def tflite_predict(tflite_interpreter, input_index, output_index, x):
tflite_interpreter.set_tensor(input_index, x)
Expand All @@ -127,8 +127,8 @@ def tflite_predict(tflite_interpreter, input_index, output_index, x):
inference_framework = "onnx"
wakeword_models = [i.replace('.tflite', '.onnx') for i in wakeword_models]
else:
raise ValueError("Tried to import the tflite runtime for provided tflite models, but it was not found. "
"Please install it using `pip install tflite-runtime`")
raise ValueError("Tried to import the LiteRT runtime for provided LiteRT models, but it was not found. "
"Please install it using `pip install ai-edge-litert`")

if inference_framework == "onnx":
try:
Expand Down
6 changes: 3 additions & 3 deletions openwakeword/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def __init__(self,

elif inference_framework == "tflite":
try:
import tflite_runtime.interpreter as tflite
import ai_edge_litert.interpreter as tflite
except ImportError:
raise ValueError("Tried to import the TFLite runtime, but it was not found."
"Please install it using `pip install tflite-runtime`")
raise ValueError("Tried to import the LiteRT runtime, but it was not found."
"Please install it using `pip install ai-edge-litert`")

if melspec_model_path == "":
melspec_model_path = os.path.join(pathlib.Path(__file__).parent.resolve(),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ authors = [
]
description = "An open-source audio wake word (or phrase) detection framework with a focus on performance and simplicity"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down
31 changes: 17 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,35 @@
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()


# Build extras_requires based on platform
def build_additional_requires():
py_version = platform.python_version()[0:3].replace('.', "")
if platform.system() == "Linux" and platform.machine() == "x86_64":
additional_requires=[
f"speexdsp_ns @ https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp{py_version}-cp{py_version}-linux_x86_64.whl",
]
elif platform.system() == "Linux" and platform.machine() == "aarch64":
additional_requires=[
f"speexdsp_ns @ https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp{py_version}-cp{py_version}-linux_aarch64.whl",
],
elif platform.system() == "Windows" and platform.machine() == "x86_64":
additional_requires=[
# py_version = platform.python_version()[0:3].replace('.', "")
# if platform.system() == "Linux" and platform.machine() == "x86_64":
# additional_requires=[
# f"speexdsp_ns @ https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp{py_version}-cp{py_version}-linux_x86_64.whl",
# ]
# elif platform.system() == "Linux" and platform.machine() == "aarch64":
# additional_requires=[
# f"speexdsp_ns @ https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp{py_version}-cp{py_version}-linux_aarch64.whl",
# ],
if platform.system() == "Windows" and platform.machine() == "x86_64":
additional_requires = [
'PyAudioWPatch'
]
else:
additional_requires = []

return additional_requires


setuptools.setup(
name="openwakeword",
version="0.6.0",
install_requires=[
'onnxruntime>=1.10.0,<2',
'tflite-runtime>=2.8.0,<3; platform_system == "Linux"',
'ai-edge-litert>=2.0.2,<3; platform_system == "Linux" or platform_system == "Darwin"',
'speexdsp-ns>=0.1.2,<1; platform_system == "Linux"',
'tqdm>=4.0,<5.0',
'scipy>=1.3,<2',
'scikit-learn>=1,<2',
Expand All @@ -40,7 +43,7 @@ def build_additional_requires():
'pytest>=7.2.0,<8',
'pytest-cov>=2.10.1,<3',
'pytest-flake8>=1.1.1,<2',
'flake8>=4.0,<4.1',
'flake8>=5.0,<7.1',
'pytest-mypy>=0.10.0,<1',
'types-requests',
'types-PyYAML',
Expand Down Expand Up @@ -90,5 +93,5 @@ def build_additional_requires():
],
packages=setuptools.find_packages(),
include_package_data=True,
python_requires=">=3.7",
python_requires=">=3.10",
)
7 changes: 6 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ def test_load_models_by_path(self):
os.path.join("openwakeword", "resources", "models", "alexa_v0.1.onnx")
], inference_framework="onnx")

# Prediction on random data
prediction = owwModel.predict(np.random.randint(-1000, 1000, 1280).astype(np.int16))
assert prediction["alexa_v0.1"] >= 0 and prediction["alexa_v0.1"] <= 1

owwModel = openwakeword.Model(wakeword_models=[
os.path.join("openwakeword", "resources", "models", "alexa_v0.1.tflite")
], inference_framework="tflite")

# Prediction on random data
owwModel.predict(np.random.randint(-1000, 1000, 1280).astype(np.int16))
prediction = owwModel.predict(np.random.randint(-1000, 1000, 1280).astype(np.int16))
assert prediction["alexa_v0.1"] >= 0 and prediction["alexa_v0.1"] <= 1

def test_predict_with_different_frame_sizes(self):
# Test with binary model
Expand Down