Skip to content

Commit 506c795

Browse files
committed
Merge branch 'main' into self_confirm
2 parents 1884a4f + af923e1 commit 506c795

File tree

10 files changed

+52
-30
lines changed

10 files changed

+52
-30
lines changed

.github/workflows/build_and_publish_to_pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@master
16-
- name: Set up Python 3.8
16+
- name: Set up Python 3.10
1717
uses: actions/setup-python@v3
1818
with:
19-
python-version: "3.8"
19+
python-version: "3.10"
2020
- name: Install pypa/build
2121
run: >-
2222
python -m

.github/workflows/tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.8"]
18+
python-version: ["3.10"]
1919

2020
steps:
2121
- uses: actions/checkout@v3
@@ -28,7 +28,6 @@ jobs:
2828
sudo apt-get install libspeexdsp-dev
2929
python -m pip install --upgrade pip
3030
pip install -e .[test]
31-
pip install https://github.com/dscripka/openWakeWord/releases/download/v0.1.1/speexdsp_ns-0.1.2-cp38-cp38-linux_x86_64.whl
3231
- name: Test with pytest
3332
run: |
3433
pytest
@@ -37,7 +36,7 @@ jobs:
3736
runs-on: windows-latest
3837
strategy:
3938
matrix:
40-
python-version: ["3.8"]
39+
python-version: ["3.10"]
4140

4241
steps:
4342
- uses: actions/checkout@v3

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,18 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Most notebooks
132+
notebooks/
133+
!notebooks/automatic_model_training.ipynb
134+
!notebooks/converting_google_speech_embedding_model.ipynb
135+
!notebooks/performance_metrics.ipynb
136+
!notebooks/training_models.ipynb
137+
!training_tutorial_data
138+
139+
# Most example files
140+
examples/
141+
!examples/audio/activation.wav
142+
143+
# archive files
144+
archive/

openwakeword/custom_verifier_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_reference_clip_features(
6262
# Get predictions
6363
for _ in range(N):
6464
# Load clip
65-
if type(reference_clip) == str:
65+
if isinstance(reference_clip, str):
6666
sr, dat = scipy.io.wavfile.read(reference_clip)
6767
else:
6868
dat = reference_clip

openwakeword/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ def __init__(self,
803803
self.n_per_class = {}
804804
for lbl, shape in self.shapes.items():
805805
dummy_data = np.random.random((10, self.shapes[lbl][1], self.shapes[lbl][2]))
806-
if self.data_transform_funcs.get(lbl, None):
807-
scale_factor = self.data_transform_funcs.get(lbl, None)(dummy_data).shape[0]/10
806+
if (transform_func := self.data_transform_funcs.get(lbl, None)):
807+
scale_factor = transform_func(dummy_data).shape[0]/10
808808

809809
ratio = self.shapes[lbl][0]/sum([i[0] for i in self.shapes.values()])
810810
self.n_per_class[lbl] = max(1, int(int(batch_size*ratio)/scale_factor))

openwakeword/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(
116116
# Do imports for inference framework
117117
if inference_framework == "tflite":
118118
try:
119-
import tflite_runtime.interpreter as tflite
119+
import ai_edge_litert.interpreter as tflite
120120

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

138138
if inference_framework == "onnx":
139139
try:

openwakeword/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ def __init__(self,
9494

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

102102
if melspec_model_path == "":
103103
melspec_model_path = os.path.join(pathlib.Path(__file__).parent.resolve(),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ authors = [
1818
]
1919
description = "An open-source audio wake word (or phrase) detection framework with a focus on performance and simplicity"
2020
readme = "README.md"
21-
requires-python = ">=3.7"
21+
requires-python = ">=3.10"
2222
classifiers = [
2323
"Programming Language :: Python :: 3",
2424
"License :: OSI Approved :: Apache Software License",

setup.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,35 @@
44
with open("README.md", "r", encoding="utf-8") as fh:
55
long_description = fh.read()
66

7+
78
# Build extras_requires based on platform
89
def build_additional_requires():
9-
py_version = platform.python_version()[0:3].replace('.', "")
10-
if platform.system() == "Linux" and platform.machine() == "x86_64":
11-
additional_requires=[
12-
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",
13-
]
14-
elif platform.system() == "Linux" and platform.machine() == "aarch64":
15-
additional_requires=[
16-
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",
17-
],
18-
elif platform.system() == "Windows" and platform.machine() == "x86_64":
19-
additional_requires=[
10+
# py_version = platform.python_version()[0:3].replace('.', "")
11+
# if platform.system() == "Linux" and platform.machine() == "x86_64":
12+
# additional_requires=[
13+
# 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",
14+
# ]
15+
# elif platform.system() == "Linux" and platform.machine() == "aarch64":
16+
# additional_requires=[
17+
# 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",
18+
# ],
19+
if platform.system() == "Windows" and platform.machine() == "x86_64":
20+
additional_requires = [
2021
'PyAudioWPatch'
2122
]
2223
else:
2324
additional_requires = []
2425

2526
return additional_requires
2627

28+
2729
setuptools.setup(
2830
name="openwakeword",
2931
version="0.6.0",
3032
install_requires=[
3133
'onnxruntime>=1.10.0,<2',
32-
'tflite-runtime>=2.8.0,<3; platform_system == "Linux"',
34+
'ai-edge-litert>=2.0.2,<3; platform_system == "Linux" or platform_system == "Darwin"',
35+
'speexdsp-ns>=0.1.2,<1; platform_system == "Linux"',
3336
'tqdm>=4.0,<5.0',
3437
'scipy>=1.3,<2',
3538
'scikit-learn>=1,<2',
@@ -40,7 +43,7 @@ def build_additional_requires():
4043
'pytest>=7.2.0,<8',
4144
'pytest-cov>=2.10.1,<3',
4245
'pytest-flake8>=1.1.1,<2',
43-
'flake8>=4.0,<4.1',
46+
'flake8>=5.0,<7.1',
4447
'pytest-mypy>=0.10.0,<1',
4548
'types-requests',
4649
'types-PyYAML',
@@ -90,5 +93,5 @@ def build_additional_requires():
9093
],
9194
packages=setuptools.find_packages(),
9295
include_package_data=True,
93-
python_requires=">=3.7",
96+
python_requires=">=3.10",
9497
)

tests/test_models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ def test_load_models_by_path(self):
5353
os.path.join("openwakeword", "resources", "models", "alexa_v0.1.onnx")
5454
], inference_framework="onnx")
5555

56+
# Prediction on random data
57+
prediction = owwModel.predict(np.random.randint(-1000, 1000, 1280).astype(np.int16))
58+
assert prediction["alexa_v0.1"] >= 0 and prediction["alexa_v0.1"] <= 1
59+
5660
owwModel = openwakeword.Model(wakeword_models=[
5761
os.path.join("openwakeword", "resources", "models", "alexa_v0.1.tflite")
5862
], inference_framework="tflite")
5963

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

6368
def test_predict_with_different_frame_sizes(self):
6469
# Test with binary model

0 commit comments

Comments
 (0)