mirror of
https://github.com/dscripka/openWakeWord.git
synced 2026-08-27 18:17:20 -04:00
Added tests for reset methods
This commit is contained in:
parent
528f4bff2c
commit
e9eade7aac
1 changed files with 27 additions and 3 deletions
|
|
@ -39,6 +39,7 @@ import platform
|
|||
import pickle
|
||||
import tempfile
|
||||
import mock
|
||||
import wave
|
||||
|
||||
# Download models needed for tests
|
||||
openwakeword.utils.download_models()
|
||||
|
|
@ -212,9 +213,6 @@ class TestModels:
|
|||
# Load model with defaults
|
||||
owwModel = openwakeword.Model()
|
||||
|
||||
# Get test clip
|
||||
os.path.join("tests", "data", "alexa_test.wav")
|
||||
|
||||
# Predict with chunks of 1280 with and without debounce
|
||||
predictions = owwModel.predict_clip(os.path.join("tests", "data", "alexa_test.wav"),
|
||||
debounce_time=0, threshold={"alexa_v0.1": 0.5})
|
||||
|
|
@ -227,6 +225,32 @@ class TestModels:
|
|||
assert (scores >= 0.5).sum() > 1
|
||||
assert (scores_with_debounce >= 0.5).sum() == 1
|
||||
|
||||
def test_model_reset(self):
|
||||
# Load the model
|
||||
owwModel = openwakeword.Model()
|
||||
|
||||
# Get test clip and load it
|
||||
clip = os.path.join("tests", "data", "alexa_test.wav")
|
||||
with wave.open(clip, mode='rb') as f:
|
||||
data = np.frombuffer(f.readframes(f.getnframes()), dtype=np.int16)
|
||||
|
||||
# Predict frame by frame
|
||||
for i in range(0, len(data), 1280):
|
||||
prediction = owwModel.predict(data[i:i+1280])
|
||||
if prediction['alexa'] > 0.5:
|
||||
break
|
||||
|
||||
# Assert that next prediction is still > 0.5
|
||||
prediction = owwModel.predict(data[i:i+1280])
|
||||
assert prediction['alexa'] > 0.5
|
||||
|
||||
# Reset the model
|
||||
owwModel.reset()
|
||||
|
||||
# Assert that next prediction is < 0.5
|
||||
prediction = owwModel.predict(data[i:i+1280])
|
||||
assert prediction['alexa'] < 0.5
|
||||
|
||||
def test_models_with_vad(self):
|
||||
# Load model with defaults
|
||||
owwModel = openwakeword.Model(vad_threshold=0.5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue